Unable to signin with Next-auth in production

1.6k views Asked by At

I've deployed my next.js application in vercel and I use Next-auth for authentication. In my app user can signin with google OAuth and it works perfectly locally but in production the user is not able to signin

When i check the logs of my deployment this is what i see enter image description here

Here the cache says MISS I found this issue in github and tried to override the header both in next.config.js and in the auth handler but the bug is still not fixed.

what am i missing out? here is the link to my project repository: https://github.com/alphawhiskey03/bmi-api

2

There are 2 answers

0
MBŠ On BEST ANSWER

in development we put next auth url in the .env file

NEXTAUTH_URL=http://localhost:3000

make sure to put this in production to your new domain

NEXTAUTH_URL= your new domain here
1
Radmehr On

Read the log of Google auth page. It is possible that you pass redirect URL or main URL wrong.

Please check the Redirect URL in your Google console and what you pass in env of your app in Vercel. It is possible that your Redirect URL is localhost and NOT the Vercel URL!