Open alimozdemir opened 3 weeks ago
Likely the same issue as #479. Seems to be caused in this part of useAuth.ts
, in which a URLSearchParams is thrown in a fetch as request body.
@Invisi Yes exactly, that is the initial point then server tries to parse the body and throws an exception.
I experience the same error, I am not able to log out of my application at the moment. Could you maybe treat this bug as a high prio one?
Hi @alimozdemir @Dunowen, I need to confirm why are we providing search params as body. This seemed to work so far, but apparently something changed in one of our dependencies (h3
).
I will investigate today.
Is there any update on this?
After some investigation, I can confirm that this is a bug with h3
- using URLSearchParams
is intended:
https://github.com/nextauthjs/next-auth/blob/285cb5ce166bdc1dc99013f0da538186c5be6e0b/packages/next-auth/src/react.tsx#L265-L280
@phoenix-ru that's why I tested h3 individually for URLSearchParams in a simple code. But it was ok, it was working
Environment
Darwin
v20.11.1
3.12.4
3.13.0
2.9.7
pnpm@8.15.4
-
modules
,extends
,future
,css
,app
,runtimeConfig
,auth
,compatibilityDate
@nuxtjs/tailwindcss@6.12.1
,@nuxt/fonts@0.7.2
,@vueuse/nuxt@10.11.1
,@sidebase/nuxt-auth@0.8.2
-
Reproduction
It is hard to reproduce this error without sharing the secrets. But I did a debugging with loading nuxt-auth package directly from the source. I will describe all findings.
Describe the bug
First of all I would like to share my handler file.
Whenever I login or logout I receive following exception
[500] The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of URLSearchParams
error on https://github.com/sidebase/nuxt-auth/blob/c5a62d99784a64cd208a0845da0a37461337f7cc/src/runtime/server/services/authjs/nuxtAuthHandler.ts#L206
somehow, h3 package readBody throws this error, but I already test that readBody function with URLSearchParams object in a clean project and it is working ok.
The only thing that I found is
https://github.com/unjs/h3/blob/853ae882b58927bbc8eed41b9c02fa7efc529192/src/utils/body.ts#L47
this
_rawBody
variable is empty on simple tests in a sandbox, but when nuxt-auth sends URLSearchParams object, it is filled. In my sandbox tests, it's not hitting the next if condition and does not throw the error onhttps://github.com/unjs/h3/blob/853ae882b58927bbc8eed41b9c02fa7efc529192/src/utils/body.ts#L93
Additional context
No response
Logs