Hey Auth0 team!
I’ve been banging my head against the wall in search of a solution to an issue I’m having getting the callbacks to to work in production after login and logout. It seems that both the login and logout functions are working in both environments but on redirect I’m consistently getting an error in production. Some context first on what I’ve tried:
I have an application built with NextJS that uses the Auth0 SDK for user registration and login. It’s been working well locally and has historically worked well upon deployment to Vercel. Today, it stopped working in “production” on Vercel. I’ve done the following to troubleshoot but can’t quite track down the root cause:
- Moved all of my production environment variables into Vercel. This is what my .env.production file in my repo looks like currently.
AUTH0_SECRET=${AUTH0_SECRET}
AUTH0_BASE_URL=${AUTH0_BASE_URL}
AUTH0_ISSUER_BASE_URL='https://dev-34dtsap5c884eh3q.us.auth0.com'
AUTH0_CLIENT_ID=${AUTH0_CLIENT_ID}
AUTH0_CLIENT_SECRET=${AUTH0_CLIENT_SECRET}
- Created a separate Auth0 application for the Vercel environment. With the following Application URIs:
- Allowed Callback URLs: https://tandem-five.vercel.app/api/auth/callback
- Allowed Logout URLs: https://tandem-five.vercel.app/
Here is the Auth0 file for reference:
/src/pages/api/auth/[…auth0].js
import { handleAuth, handleLogin } from '@auth0/nextjs-auth0';
export default handleAuth({
onError(req, res, error) {
console.log(error);
console.log(req)
res.status(error.status || 500).end('Check the console for the error');
}
});
I’m sure there’s a straightforward reason - but I haven’t found it yet in my attempts to fix and in the other articles with similar subjects. If there’s any guidance on troubleshooting on my own further, please let me know. Otherwise, any guidance on a potential root cause would help!
Thanks