I am able to log in and redirect to my redirectURI path but I get an error “Cannot destructure property ‘name’ of ‘user’ as it is undefined.” and isAuthenticated returns false.
I have a file where I create the Auth0 provider and set the redirectURI:
import React from 'react';
import { useNavigate } from 'react-router-dom';
import { Auth0Provider } from '@auth0/auth0-react';
const Auth0ProviderWithHistory = ({ children }) => {
const domain = process.env.REACT_APP_AUTH0_DOMAIN;
const clientId = process.env.REACT_APP_AUTH0_CLIENT_ID;
const history = useNavigate();
const onRedirectCallback = (appState) => {
history.push(
appState && appState.returnTo
? appState.returnTo
: window.location.pathname
);
};
return (
<Auth0Provider
domain={domain}
clientId={clientId}
redirectUri="http://localhost:3003/workspace"
onRedirectCallback={onRedirectCallback}
>
{children}
</Auth0Provider>
);
};
export default Auth0ProviderWithHistory;
and this is my login file:
const LoginButton = () => {
const { loginWithRedirect } = useAuth0();
return (
<div className="App">
<NavBar />
<button
className="btn btn-login"
onClick={() => loginWithRedirect()}
>
Log In
</button>
</div>
);
};
export default LoginButton;
I’ve included http://localhost:3003/workspace in my Allowed Callback URLs and Allowed Web Origins. Am I missing anything? Thank you!