sidebase / nuxt-auth

Authentication built for Nuxt 3! Easily add authentication via OAuth providers, credentials or Email Magic URLs!
https://auth.sidebase.io
MIT License
1.25k stars 162 forks source link

`signoutData` might be `undefined` #823

Open LLCampos opened 2 months ago

LLCampos commented 2 months ago

Environment

- Node Version:     v18.17.0
- Nuxt Version:     3.11.2
- CLI Version:      3.11.1
- Nitro Version:    2.9.6
- Package Manager:  npm@9.9.3
- User Config:      experimental, extends, modules, sourcemap, app, css, postcss, auth, vite, runtimeConfig
- Runtime Modules:  @sidebase/nuxt-auth@^0.7.2, @pinia/nuxt@0.5.1, @formkit/nuxt@1.6.3, @nuxt/devtools@1.3.2, @nuxtjs/tailwindcss@^6.8.0, floating-vue/nuxt
- Build Modules:    -

Reproduction

This is a non-deterministic problem. Not able to reproduce it consistently.

Describe the bug

We've been non-deterministically been getting the error

TypeError: undefined is not an object (evaluating 'o.url') / TypeError: o is undefined

The source maps tell me that the error is happening here.

So it seems that somehow signoutData might be undefined at this point?

Additional context

I'll add more context here if I find anything new.

Logs

No response

phoenix-ru commented 2 months ago

Hi @LLCampos . I checked and it's probably caused by redirects

Here's what next-auth v4 does:

POST: https://github.com/nextauthjs/next-auth/blob/8fd11333c5f5d426a741674b0a02def723e4aa31/packages/next-auth/src/core/index.ts#L254-L261

And here's how we handle it in 0.8: https://github.com/sidebase/nuxt-auth/blob/9295d1fe4f27d42c879862a48202f5b215fc0048/src/runtime/server/services/authjs/nuxtAuthHandler.ts#L171-L176

So, the body with url is only returned when next-auth returns a body with JSON, thus probably making the problem inconsistent for you.

Since we are working on a revamp of authjs in #818, it might be the case that this problem is solved there. Please keep an eye out on a new release to see if it helps.