onRedirectCallback takes me back to my redirectURI for a split second before redirecting

Hi Guys,

I’m using the React SDK (in a next.js project) and struggling with this little issue that I can’t figure out the solution to!

So in my top-level app component, I have my Auth provider configured like so

const onRedirectCallback = (appState: AppState) => {
   Router.replace(appState?.returnTo || '/');
};

<Auth0Provider
    domain="process.env.AUTH_DOMAIN"
    clientId="process.env.AUTH_CLIENT_ID"
    redirectUri="http://localhost:3000/"
    audience="process.env.AUTH_AUDIENCE"
    onRedirectCallback={onRedirectCallback}
>
    <Component {...pageProps} />
</Auth0Provider>

I’m using withAuthenticationRequired to lock down a protected page. So when I visit this page, it correctly re-directs me to log in. Once I’ve logged in, it takes me back to the homepage of my app, briefly flashes the content for a split second before taking me back to the call back URL.

Any ideas of what could be causing this issue?