Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When guest user accesses a protected page with CredentialsProvider settings, an error occurs #937

Open
andreabasile opened this issue Oct 25, 2024 · 1 comment
Labels
bug A bug that needs to be resolved question A question about NuxtAuth

Comments

@andreabasile
Copy link

andreabasile commented Oct 25, 2024

Environment


  • Operating System: Darwin
  • Node Version: v20.2.0
  • Nuxt Version: 3.13.2
  • CLI Version: 3.14.0
  • Nitro Version: 2.9.7
  • Package Manager: [email protected]
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

Steps to Reproduce:

Configure CredentialsProvider in the Nuxt config.
Set up a protected route that requires authentication.
Open a session as a guest user and try to access the protected page.
Expected Behavior: The guest user should be redirected to the login page without seeing any error.

Actual Behavior: An error occurs, disrupting the expected flow.

Context: Include the Nuxt version, the @sidebase/nuxt-auth version, and any relevant configuration or code snippets that might help in identifying the issue.

Describe the bug

When a guest (unauthenticated) user attempts to access a protected page configured with CredentialsProvider settings, an error is triggered. Expected behavior would be a redirect to the login page, but instead, an error page appears.

receive 500 status code

Additional context

No response

Logs

ERROR [nuxt] [request error] [unhandled] [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
at __node_internal_captureLargerStackTrace (node:internal/errors:490:5)
at new NodeError (node:internal/errors:399:5)
at Function.from (node:buffer:324:9)
at ./node_modules/h3/dist/index.mjs:410:21
at async readBody (./node_modules/h3/dist/index.mjs:438:16)
at createRequestForAuthjs (./node_modules/@sidebase/nuxt-auth/dist/runtime/server/services/authjs/nuxtAuthHandler.js:123:70)
at Object.handler (./node_modules/@sidebase/nuxt-auth/dist/runtime/server/services/authjs/nuxtAuthHandler.js:42:25)
at async ./node_modules/h3/dist/index.mjs:1975:19
at async Object.callAsync (./node_modules/unctx/dist/index.mjs:72:16)
at async toNodeHandle (./node_modules/h3/dist/index.mjs:2266:7)
at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)
at async $fetchRaw2 (./node_modules/ofetch/dist/shared/ofetch.4747642d.mjs:249:26)
at async $fetch2 (./node_modules/ofetch/dist/shared/ofetch.4747642d.mjs:304:15)
at async Object.callAsync (./node_modules/unctx/dist/index.mjs:72:16)
at async signIn (./node_modules/@sidebase/nuxt-auth/dist/runtime/composables/authjs/useAuth.js:92:16)
at async Object.callAsync (./node_modules/unctx/dist/index.mjs:72:16)
at async ./node_modules/nuxt/dist/pages/runtime/plugins/router.js:189:26

No response

@andreabasile andreabasile added bug A bug that needs to be resolved pending An issue waiting for triage labels Oct 25, 2024
@phoenix-ru
Copy link
Collaborator

Please look into #883

You may need upgrading to a fresh h3

@phoenix-ru phoenix-ru added question A question about NuxtAuth and removed pending An issue waiting for triage labels Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug that needs to be resolved question A question about NuxtAuth
Projects
None yet
Development

No branches or pull requests

2 participants