Nextjs-auth0 stops to work in production

Hello everyone,

I’m encountering an issue with the nextjs-auth0 SDK.

I followed all the necessary configurations to enable login in my application, as outlined in the tutorial on the Auth0 website.

During development, everything worked seamlessly. I could log in, access user information, perform logouts, and more.

However, after building my application and transitioning to production mode, the SDK stopped functioning entirely. I noticed that the cookies defining the session (defaulted to “appSession”) are set upon login in production mode. However, upon navigating to a different page (changing the URL), the cookies are sent to the page but disappear when it loads, resulting in a loss of the user’s session.

Additionally, I observed that in production mode, another cookie named “auth_verification” appears alongside appSession. Unlike appSession, “auth_verification” persists throughout the application’s lifespan.

I’ve attempted adjusting the cookie security settings and manually initializing the SDK, but none of these alternatives have resolved the issue.

Does anyone have any insights into what might be happening and how I can resolve it? I’ve tried various approaches but haven’t found a solution.

Note:

  • My project is using version 14.0.4 of Nextjs.
  • I’m utilizing version 3.5.0 of the SDK.

Thanks in advance for any assistance!

1 Like

Running into the same issue.

In fact, I noticed that it was my fault, and I found the error.

I was using the <Link/> tag for the redirects of the Auth0 API. However, it will generate this kind of error since the Link component is meant to perform client-side transitions between pages. As the link points to an API route and not to a page, you should keep it as an anchor tag.

So, to solve the problem, simply substitute the <Link/> tag with an anchor tag <a/>.

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