React SPA doesn't login on refresh

Hi, I’m having a problem where the user doesn’t remain authenticated when I refresh the browser and the second one is that when I set the route on the address bar and tried to login it doesn’t redirect it to that route.

I tried to reproduce the problem in codesandbox but it doesn’t work on firefox but in chrome instead.

1 Like

Hi, @isemaj

First of all, I’m sorry for the delay in the response. I’m not sure if you still have this issue, but I’ll try helping troubleshoot.

There are different ways to redirect users after login authentication, but if you are following our react quickstart, you probably had to configure the Callback URLs from the dashboard. A callback URL is a URL in your application where Auth0 redirects the user after they have authenticated.

The callback URL for your app must be whitelisted in the Allowed Callback URLs field in your Application Settings. If this field is not set, users will be unable to log in to the application and will get an error.

Also, I noticed that in your code in Nav.tsx you don’t have loginWithRedirect in this line: const { isAuthenticated, logout } = useAuth0();

Are you trying to do another redirect flow?

Please let me know.