nextauthjs / next-auth

Authentication for the Web.
https://authjs.dev
ISC License
24.15k stars 3.35k forks source link

OAuthSignin Error in Vercel Deployment #7640

Open kaganAhmetOkan opened 1 year ago

kaganAhmetOkan commented 1 year ago

Provider type

Spotify

Environment

System: OS: Linux 5.19 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish) CPU: (4) x64 Intel(R) Core(TM) i3-7020U CPU @ 2.30GHz Memory: 8.52 GB / 11.57 GB Container: Yes Shell: 5.8.1 - /bin/zsh

Binaries: Node: 19.9.0 - /usr/bin/node Yarn: 1.22.19 - /usr/bin/yarn npm: 9.6.3 - /usr/bin/npm

Browsers: Chrome: 113.0.5672.126 Firefox: 113.0.2

Reproduction URL

https://github.com/kaganAhmetOkan/nextjs-spotify-clone

Describe the issue

NextAuth fails to log into Spotify in Vercel Deployed version, but works fine in localhost development mode.

The project will redirect the user to the login page, where clicking the "login with spotify" should redirect them to the index, but instead the URL returned is an error: https://nextjs-spotify-clone-iota.vercel.app/login?callbackUrl=https%3A%2F%2Fnextjs-spotify-clone-iota.vercel.app%2F&error=OAuthSignin

How to reproduce

The problem should only happen in the deployed version, and not the development version.

May be important: I forgot to add NEXTAUTH_URL env variable at the beginning of deployment. I since added it and redeployed the project to find the same error. I've also added NEXTAUTH_SECRET and it also did not fix the issue.

Expected behavior

Signin should have opened a new window where Spotify would ask you to signin, confirm that you wanted to give permissions to my project, and redirect to the site.

CRYBOII commented 1 year ago

same here

Takzzg commented 1 year ago

i have the same issue using google auth. I think the problem in my case is when trying to import something from [...nextauth].ts ie: import { onUserLogIn } from "./utilities" commenting that line out seems to fix the issue. i tried importing from outside the pages folder too but it still breaks. Am I missing any config options anywhere ? every other import (from libraries) works fine