I have a hosted website running nextjs and am using the nextjs-auth0 module for authentication. This was working fine but hitting auth/login (initially through Google SSO) using a particular browser session results in a 502 error. The same exact process works fine in a new window (with a different generated state of course). Any idea of why this is happening?
When trying to sign in the Auth0 callback calls my nextjs /api/auth/callback api route which executes the callback method in the nextjs-auth0 package. This is returning a 502.
It simply performs a call to handleLoginWindowOpener function.
const handleLoginWindowOpener = async () => {
window.open('/login/api/auth/logout','_blank');
}
// ----------------------------------------------------
return (
<header>
<span className="text-md text-pink">
<button onClick={handleLoginWindowOpener}>{sessionInfo.user ? 'Click to logout.' : 'Click to login or to create an account.'}</button>
</span>
<span className="text-md text-gray">
{' | '}{hostname} {sessionInfo.token?.expiry ? ` (current login valid till ${timestampToDateString(sessionInfo.token.expiry)})` : ' (logged out)'}
</span>
</header>
)
}
Issue happens on one particular instance after attempting to/signing in using Google. There is nothing in the nginx logs either, seems like the call didn’t reach the server.
The route you are using looks a bit odd, typically we see /api/auth/logout, instead of /login/api/auth/logout. Is it possible this route is causing the issue?
The /login/ route is being captured by nginx and forwarded accordingly (correct route/port). I’ve never encountered any issues apart from this specific instance and it works as expected if opened in a new window.