Getting Double pathname after authentication

Our domain is “www.abc.comm”, and we use language codes in the URL (e.g., /en/ for English). We have set /en/business-group/cart as the callback URL in Auth0 for authentication. This setup was working correctly, but recently, after authentication, users are being redirected to an incorrect URL such as www.abc.com/en/business-group/cart/en/business-group/cart instead of the intended www.abc.com/en/business-group/cart.

We noticed that the response header from the Auth0 callback contains a Location key with this incorrect path. This issue is affecting all our applications, and the redirect path seems to vary based on the selected language. We are unable to identify the root cause and cannot provide even a temporary fix at this time. Our project is built with Next.js.

Can anyone help us identify the root cause of this redirect issue and suggest a solution?

Hi @rajkums,

Welcome to the Auth0 Community and sorry for the delayed response.

Given that you are using locales within your application, the most probable cause of this issue would be misinterpretation of the state parameter sent to your callback URL. During the callback, your application is likely retrieving the state parameter and using it to determine the next redirect path. If the state parameter itself contains the callback URL, it will be redundantly appended to the base callback URL, resulting in a duplicate path, so you will have to make sure that the configuration of the Redirect URI is correct within your application’s code.

Leaving this documentation links here in case they come in useful:

One solution that I can think of would be constructing The returnTo parameter by extracting the locale directly from the URL to something similar to: const returnToUrl = `${appBaseUrl}/${locale}/business-group/cart` and passing it to the /auth/login route.

Hopefully this helps and if you have further questions please let me know!

Thanks,

Remus

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.