I have a React app that uses the auth0-react
package and the useAuth0
hook. In my local environment that is using Auth0 dev keys, I can log in and out, and my session persists fine.
In my production instance, once I log in for the first time, I am able to access the user info. But if I try to navigate to another page or refresh, the user’s session is gone, and IsAuthenticated
is false
.
I have useRefreshToken={true}
in my provider and refresh tokens active in my Auth0 dashboard. I have configured my Auth0 config for the app & Google Oauth to have my production URL as an allowed origin and the profile page as a callback URI. Cannot figure out why this is happening. I am using Chrome
return (
<Auth0Provider
domain={domain}
clientId={clientId}
authorizationParams={{
redirect_uri: redirectUri,
}}
useRefreshTokens={true}
onRedirectCallback={onRedirectCallback}
>
{children}
</Auth0Provider>
Login method
const handleLogin = async () => {
await loginWithRedirect({
appState: {
returnTo: "/profile",
},
});
};
my navbar code that shows user on initial login, and gives undefined, false
after navigating
const { user, logout, isLoading, isAuthenticated} = useAuth0();
console.log(user, isAuthenticated);