I'm not seeing redirects defined in the "Browser Redirects" tab in the console being passed down to the browser. I'm using the example next.js code and their login submit code block looks like the following...
const onSubmit = (values: SubmitSelfServiceLoginFlowBody) =>
router
.push(`/account/login?flow=${flow?.id}`, undefined, { shallow: true })
.then(() =>
ory
.submitSelfServiceLoginFlow(String(flow?.id), undefined, values)
.then((res) => {
console.log("FLOW", flow)
if (flow?.return_to) {
// THIS never gets hit
// as `return_to` is never found in the flow obj
window.location.href = flow?.return_to
return
}
router.push('/')
})
.then(() => {})
.catch(handleFlowError(router, 'login', setFlow))
.catch((err: AxiosError) => {
if (err.response?.status === 400) {
setFlow(err.response?.data)
return
}
return Promise.reject(err)
})
)
Use above snippet to submit login and try and catch redirects.
Example Flow log output from the code snippet above...
{
"id": "<REDACTED>",
"type": "browser",
"expires_at": "2022-02-15T02:27:01.572505Z",
"issued_at": "2022-02-15T01:27:01.572505Z",
"request_url": "http://<REDACTED>.projects.oryapis.com/self-service/login/browser?",
"ui": {
"action": "/api/.ory/api/kratos/public/self-service/login?flow=<REDACTED>",
"method": "POST",
"nodes": [
{
"type": "input",
"group": "default",
"attributes": {
"name": "csrf_token",
"type": "hidden",
"value": "<REDACTED>",
"required": true,
"disabled": false,
"node_type": "input"
},
"messages": [],
"meta": {}
},
{
"type": "input",
"group": "password",
"attributes": {
"name": "password_identifier",
"type": "text",
"value": "",
"required": true,
"disabled": false,
"node_type": "input"
},
"messages": [],
"meta": {
"label": {
"id": 1070004,
"text": "ID",
"type": "info"
}
}
},
{
"type": "input",
"group": "password",
"attributes": {
"name": "password",
"type": "password",
"required": true,
"disabled": false,
"node_type": "input"
},
"messages": [],
"meta": {
"label": {
"id": 1070001,
"text": "Password",
"type": "info"
}
}
},
{
"type": "input",
"group": "password",
"attributes": {
"name": "method",
"type": "submit",
"value": "password",
"disabled": false,
"node_type": "input"
},
"messages": [],
"meta": {
"label": {
"id": 1010001,
"text": "Sign in",
"type": "info",
"context": {}
}
}
}
]
},
"created_at": "2022-02-15T01:27:01.578772Z",
"updated_at": "2022-02-15T01:27:01.578772Z",
"refresh": false,
"requested_aal": "aal1"
}