Issue with Next.js Authentication Callback URL on Heroku
Unanswered
Ragdoll posted this in #help-forum
RagdollOP
### Summary
Description:
I am encountering an issue with my Next.js application deployed on Heroku, specifically related to the callback URL for authentication. Here's a summary of the problem:
Issue
I have implemented authentication in my Next.js app using the
In production, when users click the "Login with GitHub" button, they are redirected to a
Environment
- Next.js app using
- Deployed on Heroku
- Environment variables are correctly set, including
Error Messages
- When users click the login button, they are redirected to
- The browser console shows the error: "crbug/1173575, non-JS module files deprecated."
Steps Taken
- Checked and verified that
- Restarted Heroku dynos.
- Added
Expected Behavior
When clicking the login button, users should be redirected to the Heroku app's URL for authentication (
Description:
I am encountering an issue with my Next.js application deployed on Heroku, specifically related to the callback URL for authentication. Here's a summary of the problem:
Issue
I have implemented authentication in my Next.js app using the
next-auth library, and the login buttons are configured to use the correct callbackUrl as follows:signIn('github', { callbackUrl: `${process.env.NEXT_PUBLIC_APP_URL}/api/auth/callback/github` })In production, when users click the "Login with GitHub" button, they are redirected to a
localhost URL instead of the Heroku app's URL.Environment
- Next.js app using
next-auth- Deployed on Heroku
- Environment variables are correctly set, including
NEXT_PUBLIC_APP_URLError Messages
- When users click the login button, they are redirected to
http://localhost:PORT/api/auth/callback/github.- The browser console shows the error: "crbug/1173575, non-JS module files deprecated."
Steps Taken
- Checked and verified that
NEXT_PUBLIC_APP_URL environment variable is correctly set on Heroku.- Restarted Heroku dynos.
- Added
console.log statements for debugging, which showed the correct value of NEXT_PUBLIC_APP_URL.Expected Behavior
When clicking the login button, users should be redirected to the Heroku app's URL for authentication (
https://your-heroku-app.herokuapp.com/api/auth/callback/github), not localhost.