How to go back to the original URL after authentication instead of going to the landing page?

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 is my landing page URL.

In my browser I am hitting 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 and not to

I am looking for some steps to redirect the page back to

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