nextauthjs / next-auth

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

SvelteKit Auth, (Google), TypeError ("response" must be an instance of Response) #8943

Open notarib-catcher opened 10 months ago

notarib-catcher commented 10 months ago

Provider type

Google

Environment

Environment

System:

Reproduction URL

https://github.com/notarib-catcher/fest-msite-sveltk

Describe the issue

I am hosting my sveltekit site on Vercel's Hobby plan, we're using authjs for sveltekit with google as the provider to authenticate users. The version of Authjs I'm using in live is @auth/sveltekit 0.3.10, the error is occuring even when I update to 0.3.11 (latest) The error seems to be a TypeError that occurs when attempting to login. So far, I have only attempted this with the google auth provider.

To be completely honest, I am at a loss for why this error is occuring.

How to reproduce

Since this error is rather specific to my deployment, I cannot provide a proper steps-to-reproduce, however here is the error log from vercel's runtime logs

[POST] /auth/signin/google

[auth][cause]: TypeError: "response" must be an instance of Response
    at Module.processDiscoveryResponse (file:///var/task/node_modules/oauth4webapi/build/index.js:212:15)
    at getAuthorizationUrl (file:///var/task/node_modules/@auth/core/lib/oauth/authorization-url.js:19:28)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Module.signin (file:///var/task/node_modules/@auth/core/lib/routes/signin.js:15:20)
    at async AuthInternal (file:///var/task/node_modules/@auth/core/lib/index.js:112:36)
    at async Auth (file:///var/task/node_modules/@auth/core/index.js:100:30)
    at async respond (file:///var/task/.svelte-kit/output/server/index.js:2523:22)
    at async Server.default (file:///var/task/.svelte-kit/vercel-tmp/index.js:47:3)
    at async Server.<anonymous> (/var/task/___vc/__launcher/__launcher.js:14:11367)

[auth][details]: {
  "provider": "google"
}

[auth][error][SignInError]: Read more at https://errors.authjs.dev#signinerror

Expected behavior

The user should be signed in with google

Penca53 commented 10 months ago

I also have the same issue.

notarib-catcher commented 10 months ago

Update: It seems to be fixed for my project, and the cause was the node version being used, (16 vs 18)

Penca53 commented 10 months ago

Using Node 16 it works, Node 18 doesn't. In my local machine instead, I have Node 20.6.1, which works fine too.

JHelar commented 10 months ago

I was having the exact same issue. Locally it works fine, but deployed to Vercel and the mentioned error is occurring. The fix was indeed to lower the Node version in Vercel to version 16, unfortunately Vercel does not yet support version 20+.

nasso commented 10 months ago

Had the same problem, with Node.js 18 being used on Vercel, but Node 20 locally.

We downgraded to Node.js 18 locally (and most importantly, in CI) before building and deploying the app. Fixed it!