After successful authentication from OKTA, the redirection should be back to the original URL instead of landing page. Is there a way to achieve that in OKTA?
For example,
Let’s say https://example.com is my landing page URL.
In my browser I am hitting https://example.com/page-2. When the app is not authenticated our app will be redirected to okta for authentication. Once the authentication is done, I am redirected back to https://example.com and not to https://example.com/page-2.
I am looking for some steps to redirect the page back to https://example.com/page-2.
Hey @rageshwaran.rajamani,
You have a couple of options. You can intercept the request and store the current page URL in the session storage, if your framework supports it. This involves saving the URL in the user’s session data on the server side, tied to a specific session ID. After authentication, you retrieve this URL from the session and redirect the user back to their initial page.
Alternatively, you could encode the URL information in the state
parameter during the /authorize
request. This could be a JSON object or a JWT, which is then Base64URL encoded. Post-authentication, you decode the state
parameter, extract the original URL, and use it for redirection.
Whichever method you choose depends on your app setup. Just make sure to keep your state
parameter and session data secure to avoid any potential security issues.
1 Like