You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Nextjs (react) to get or submit self service browser flows and you receive an error, it would be nice for the error message to return the redirect_to with the original return_to in the url.
So initially when I called the page I passed in the return_to and then I reload the page with the Flow Id which renders everything. But if that flow id were to expire say, it would spit out an error and we would then need to call 'http://localhost:4433/self-service/login/browse to initialize a new flow, at this point we don't have any notion of the return_to that was originally used.
Note, we use the return_to to render the page differently for different applications.
Here is an example of the error message return with the self_service_flow_expired error:
{
error: {
id: 'self_service_flow_expired',
code: 410,
status: 'Gone',
reason: 'The login flow has expired. Redirect the user to the login flow init endpoint to initialize a new login flow.',
details: { redirect_to: 'http://localhost:4433/self-service/login/browser' },
message: 'The requested resource is no longer available because it has expired or is otherwise invalid.'
}
}
Below is an example of the login screen, notice where I've commented SOLVE: which is what I'm having an issue with;
typeLoginProps={flow: SelfServiceLoginFlow;};constLogin: React.FC<LoginProps>=({ flow })=>{constsubmitFlow=async(flowId: string,values: SubmitSelfServiceLoginFlowBody)=>{awaitory.submitSelfServiceLoginFlow(flowId,undefined,values).catch(handleRedirectFlowError({redirectCallback: clientRedirectHelper,route: "login",return_to: flow.return_to})).then(()=>router.push(flow.return_to||"/"));};return(<MasterLayoutreturnTo={flow.return_to}><LoginFormFlowflow={flow}submitFlow={submitFlow}/></MasterLayout>);};constgetLoginServerSideProps: GetServerSideProps<LoginProps|any>=async({ query, req })=>{if(!query?.flow){return{redirect: {destination:
"/api/.ory/self-service/login/browser"+"?"+newURLSearchParams(queryasRecord<string,string>).toString(),// passes in the query parameters if there are anystatusCode: 302,},};}constresult=awaitory.getSelfServiceLoginFlow(query?.flowasstring,req?.headers["cookie"]).catch(handleRedirectFlowError({redirectCallback: serverRedirectHelper,route: "login",// return_to: , SOLVE: there is no way of getting the return to at this point}),);if(result&&"data"inresult){return{props: {flow: result.data,},};}else{returnresultas{redirect: Redirect};}};exportconstgetServerSideProps=withNoAuthentication(getLoginServerSideProps);exportdefaultLogin;
Describe your ideal solution
It would be nice to have the error object return the redirect_url with the initial request_url that was used to create the flow.
Otherwise another endpoint to get the configuration of the flow regardless of errors.
Workarounds or alternatives
Currently, I will be having my own database that will log the flow configuration. Upon an error I will request from this database to get the config and find the return_to url
Version
oryd/kratos:v0.8.2
Additional Context
No response
The text was updated successfully, but these errors were encountered:
This would also enable us to redirect to the requested URL if the user is already logged in (because requesting a new flow returns an error in that case).
Preflight checklist
Describe your problem
When using Nextjs (react) to get or submit self service browser flows and you receive an error, it would be nice for the error message to return the
redirect_to
with the originalreturn_to
in the url.So initially when I called the page I passed in the return_to and then I reload the page with the Flow Id which renders everything. But if that flow id were to expire say, it would spit out an error and we would then need to call
'http://localhost:4433/self-service/login/browse
to initialize a new flow, at this point we don't have any notion of the return_to that was originally used.Note, we use the return_to to render the page differently for different applications.
Here is an example of the error message return with the
self_service_flow_expired
error:Below is an example of the login screen, notice where I've commented
SOLVE:
which is what I'm having an issue with;Describe your ideal solution
It would be nice to have the error object return the redirect_url with the initial request_url that was used to create the flow.
Otherwise another endpoint to get the configuration of the flow regardless of errors.
Workarounds or alternatives
Currently, I will be having my own database that will log the flow configuration. Upon an error I will request from this database to get the config and find the
return_to
urlVersion
oryd/kratos:v0.8.2
Additional Context
No response
The text was updated successfully, but these errors were encountered: