NextAuth not working with custom domain on vercel
Unanswered
Spectacled Caiman posted this in #help-forum
Spectacled CaimanOP
For some reason, when i use my custom domain with nextauth and deploy it on vercel, login with discord will just redirect back to the login screen, but works with no issue on the vercel.app version.
10 Replies
Spectacled CaimanOP
i already set NEXTAUTH_URL in env
@Spectacled Caiman i already set NEXTAUTH_URL in env
have you add your custom domain to the redirects url on discord?
@Ray have you add your custom domain to the redirects url on discord?
Spectacled CaimanOP
That’s not the issue, The sign in button on the /api/auth page won’t even work
you sure?
Go to https://discord.com/developers/applications
Select the application you are using.
Select "OAuth 2" from the left sidebar.
Click "Add Redirect" and add https://localhost:3000/api/auth/callback/discord. Make sure domain:port is correct for your Next app.
Under "OAuth2 URL Generator", select the redirect you just added, and hit Save Changes.
Restart Next app.
Select the application you are using.
Select "OAuth 2" from the left sidebar.
Click "Add Redirect" and add https://localhost:3000/api/auth/callback/discord. Make sure domain:port is correct for your Next app.
Under "OAuth2 URL Generator", select the redirect you just added, and hit Save Changes.
Restart Next app.
if the url miss match, it won't work
Spectacled CaimanOP
I can’t even get to the discord login page, that is the issue.
Not with discord callback urls
check the log and see if there is any error
Spectacled CaimanOP
the issue is with vercel I think, found this exact issue https://stackoverflow.com/questions/72469610/nextauth-api-auth-always-return-404-on-vercel-deployment-but-work-locally