I’m encountering an issue with Auth0 integration in my Next.js application deployed on an EC2 instance. The application works perfectly in my local development environment where the environment variables are set in .env.local
. However, after deploying the app to EC2 with Nginx and SSL, and updating the allowed callback and logout URLs in Auth0, I am receiving a “Callback URL mismatch” error. Despite having the .env.production
and .env.development
files in place on the EC2 instance, the issue persists. The error message indicates that the provided redirect_uri
is not in the list of allowed callback URLs. I have verified that the URLs in Auth0’s application settings include my EC2 instance’s domain and have double-checked the configuration in my NextAuth setup to ensure it matches the allowed URLs. I am also confident that Nginx is correctly configured with SSL and proxy settings. Is it possible that the environment variables are not being correctly loaded or applied in the production environment, or could there be another issue causing this URL mismatch? Any guidance on resolving this would be greatly appreciated.
Hi @rafay.khattak,
Welcome to the Auth0 Community!
I recommend checking your tenant logs to verify the callback URL being passed into your login request’s redirect_uri
.
After doing so, you should be able to determine the incorrect callback URL value being passed in the request.
To resolve this, you could:
- Include that callback URL in the list of Allowed Callback URLs.
- Pass in the correct callback URL in the
redirect_uri
.
Thanks,
Rueben
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.