onRedirectCallback receives undefined in nexts production build static generation

Hi @aajmera - if I understand you correctly, the steps to reproduce your issue are:

  1. Run the application
  2. visit http://localhost:3000/user with no cookies
  3. Login and return to the application
  4. expect to be returned to /user - actually returned to /authenticated

If this is the case, then this is casued by simple-auth0/index.js at master · ajmeraaxesh/simple-auth0 · GitHub

When you return to the application after login, you are returned to the home page to process the state and redirect you to your state.returnTo (if specified). Since you have a router.push('/authenticated') in your home page’s render that happens after authentication - the user is redirected to /user as expected, then the code in the the homepage overrides this and redierects the user to authenticated.

I commented out the router.push('/authenticated') in simple-auth0/index.js at master · ajmeraaxesh/simple-auth0 · GitHub and the application retuned me to /user after login as expected

1 Like