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

Recursion detected at /session #973

Open
IqroNegoro opened this issue Dec 29, 2024 · 6 comments
Open

Recursion detected at /session #973

IqroNegoro opened this issue Dec 29, 2024 · 6 comments
Labels
bug A bug that needs to be resolved pending An issue waiting for triage

Comments

@IqroNegoro
Copy link

Environment


  • Operating System: Windows_NT
  • Node Version: v22.12.0
  • Nuxt Version: 3.15.0
  • CLI Version: 3.17.2
  • Nitro Version: 2.10.4
  • Package Manager: [email protected]
  • Builder: -
  • User Config: default
  • Runtime Modules: @nuxtjs/[email protected], @sidebase/[email protected]
  • Build Modules: -

Reproduction

I think i don't need minimal reproduction because this problem is happening as soon as i try to including the modules for auth

Describe the bug

My problem is when i trying to use OAuth for login with google

bun add @sidebase/nuxt-auth next-auth

config :

auth: {
    isEnabled: true,
    baseURL: "http://localhost:3000/api/auth/",
    originEnvKey: "AUTH_ORIGIN",
    provider: {
      type: "authjs",
      defaultProvider: "google"
    },
  },

endpoint in ~/server/api/auth/[...].ts

import { NuxtAuthHandler } from "#auth";
import GoogleProvider from "next-auth/providers/google";

export default NuxtAuthHandler({
    secret: process.env.AUTH_SECRET,
    providers: [
        GoogleProvider.default({
            clientId: process.env.GOOGLE_CLIENT_ID!,
            clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
        })
    ]
});

just it is, but when i load the website again ( i don't do anything)

ERROR  [@sidebase/nuxt-auth] Recursion detected at /session. Have you set the correct auth.baseURL?

i think it should work well because i have the file in auth folder in ~/server/api/auth/[...].ts < use wildcard for all routes matching

do i miss something?

Additional context

No response

Logs

ℹ nuxt-auth setup starting                                                                               
...
[sidebase-auth 17.43.28] ℹ Selected provider: authjs. Auth API location is http://localhost:3000/api/auth/, if you would like to change this, see https://auth.sidebase.io/guide/application-side/configuration#baseurl. Ensure that the NuxtAuthHandler({ ... }) is there, see https://auth.sidebase.io/guide/authjs/nuxt-auth-handler
✔ nuxt-auth setup done                                                                                   
...
ERROR  [@sidebase/nuxt-auth] Recursion detected at /session. Have you set the correct auth.baseURL?
ERROR  [@sidebase/nuxt-auth] Recursion detected at /session. Have you set the correct auth.baseURL?
ERROR  [@sidebase/nuxt-auth] Recursion detected at /session. Have you set the correct auth.baseURL?
@IqroNegoro IqroNegoro added bug A bug that needs to be resolved pending An issue waiting for triage labels Dec 29, 2024
@agracia-foticos
Copy link

Same issue

@Emehprincewill
Copy link

I got same Error

ERROR [@sidebase/nuxt-auth] Recursion detected at /session. Have you set the correct auth.baseURL?

But when I set the following config in dev mode on the nuxt,config.ts it was resolved:

auth: {
originEnvKey: 'http://localhost:3000',
baseURL: 'http://localhost:3000/api/auth',
}

@NathanD19
Copy link

Finding the same problem.
Following @Emehprincewill example gets it to work again. Not ideal.

Does not work:
originEnvKey: 'AUTH_ORIGIN',
baseURL: process.env.AUTH_BASE_URL,

@CognizanterGroup
Copy link

Yea not ideal for production. I till have same problem reading it from the runtimeconfig.

@ybybybybyb
Copy link

Just found the fix. You need to remove the slash in baseURL and if you wet the AUTH_ORIGIN, it now need to include the full path

AUTH_ORIGIN=http://localhost:3000/api/auth

@TonyBrownDev
Copy link

Same issue. Watching.

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 pending An issue waiting for triage
Projects
None yet
Development

No branches or pull requests

7 participants