#Next.js NextAuth.js OAuth false redirect url problem

1 messages · Page 1 of 1 (latest)

velvet hill
#

I created 2 different version of all my existing OAuth Provider solutions( there are 2: Github and Google). One version for Development environment, the other is for the production environment. I am adding all the client and secret key for the production one to my vercel project via "Add Environment Variables" section.

Even though I add correctly in the Settings, it throws an error, and redirecting to "localhost:3000". Help me!

maiden coveBOT
#

Hi @velvet hill. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the information provided in the extracts, it seems like you might be facing an issue with the Authorization Callback URL of your OAuth applications. This URL should match the domain of your Vercel deployment for the production environment.

For example, if you're using GitHub OAuth, the Authorization Callback URL should be set to <https://<your-vercel-project-name>.vercel.app/api/auth> or <https://<your-vercel-project-name>.vercel.app/api/github-oauth> depending on your setup.

Please ensure that you have set the correct Authorization Callback URL for your OAuth applications. Also, make sure that you have correctly set the environment variables GITHUB_ID, GITHUB_SECRET, NEXTAUTH_URL (for GitHub OAuth) in your Vercel project settings.

If you're using Google OAuth, ensure that you have set the correct environment variables for it as well. Unfortunately, the extracts do not provide specific information about Google OAuth setup.

If the issue persists, it might be due to some other factors not covered in the provided extracts. In that case, I would recommend checking the official Next.js and Vercel documentation or reaching out to their support for further assistance.

Sources:


Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: