-
-
Notifications
You must be signed in to change notification settings - Fork 174
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
Comments
Same issue |
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: { |
Finding the same problem. Does not work: |
Yea not ideal for production. I till have same problem reading it from the runtimeconfig. |
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 |
Same issue. Watching. |
From what I could tell if you have set |
i have use another nuxt module brah, i think I'll close this issue |
I had the same issue and also went with another module. Thanks for the
update!
…On Wed, Jan 8, 2025 at 9:57 PM Nadila Vira ***@***.***> wrote:
i have use another nuxt module brah, i think I'll close this issue
—
Reply to this email directly, view it on GitHub
<#973 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AID5ICIZH6YZYYI5CAVMLU32JX6U7AVCNFSM6AAAAABUKWCO4CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNZZGE4DCNJWGE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Which module did you go with @TonyBrownDev /@IqroNegoro ? |
i use Nuxt and i just need Google OAUTH2 Sign In, so i use this module, this module so straightforward for what i want : |
@NathanD19 - I ended up using https://authjs-nuxt.pages.dev/, and implemented the Google sign in provider. It seemed to work perfectly in my case. Best of luck! |
Thanks for the info! I'll take a look at these. |
why this issue is closed, its still occuring |
Yeah even after multiple people chimed in to say it was also occurring for them. @IqroNegoro can you reopen so we don't have to recreate this? Issue is real and not fixed. |
have you tried @Emehprincewill solution? |
@IqroNegoro Thanks for re-opening! 👍 I did indeed try @Emehprincewill 's solution. It did fix it for me. nuxt.config.ts: auth: {
originEnvKey: 'AUTH_ISSUER',
baseURL: `${process.env.AUTH_ORIGIN}/api/auth`,
provider: {
type: 'authjs',
defaultProvider: 'keycloak',
},
}, Setting I have these environment variables set in my AUTH_ORIGIN = http://localhost:3000
NUXT_AUTH_ISSUER = http://localhost:8080/realms/my-realm However, this seems to be just a workaround. I did not have to do this before. It would pick up the environment variables correctly without these extra two lines in nuxt.config.ts. So I'm guessing this is actually a bug somewhere. Could be a change in Note: I am setting runtimeConfig: {
AUTH_ISSUER: 'http://localhost:8080/realms/my-realm',
// ...
}, There is some mechanism that takes |
Maybe there is issue with prefix NUXT, like in next.js where some variable need prefix NEXT for working... So instead AUTH_ISSUER, maybe that need prefix NUXT before it... Idk exactly. And I have no idea why there is no one in this module team that showing up? |
After doing some more digging, I am suspecting that this issue might be related to the breakage: It specifically mentions some of the environment variables that we have to change to get things working again...
If you follow the link, it talks about Also, this commit has been changing the URL resolution just last month: Not trying to fingerpoint. Just trying to get this issue rolling. Also, just found this PR which definitely seems related: This line would explain why suddenly I need to specify // Note: the `server` condition is here because Nuxt explicitly filters out all the env variables for the Client build,
// thus the check can be safely dropped. Instead of it, the `runtime/plugin` would set the `baseURL` on the runtime config.
if (import.meta.server !== false && authRuntimeConfig.originEnvKey) {
// Override base URL using environment variable specified in `originEnvKey` if any.
// By default, would use `AUTH_ORIGIN`, can be changed by user
const envBaseURL = process.env[authRuntimeConfig.originEnvKey]
if (envBaseURL) {
baseURL = envBaseURL
}
} https://github.com/sidebase/nuxt-auth/blame/main/src/runtime/utils/url.ts#L42 Seems that if
https://auth.sidebase.io/guide/application-side/configuration#originenvkey |
I really hope this is wrong. Because origin has a very defined meaning and it explicitly does NOT include a path. It is a combination of protocol, host and port. E.g
https://developer.mozilla.org/en-US/docs/Glossary/Origin Asking for an origin and then expecting it to include a path is just wrong.... |
@zoey-kaiser Can you have a look at this issue? I suspect it is an unintended consequence of your commit 5788005 from last month. @BracketJohn Adding you as you seem to be top committer for this project. Basically the last release seems to have broken many people that now have to make workarounds in their config and we are all just guessing here. This issue needs some love from the regular maintainers. |
|
Hi @Download, thank you for a very involved investigation! I am the main author of #913 which changed quite a lot of logic regarding paths.
I absolutely agree with you here and you are correct, the name We have long considered renaming the variable to something which makes more sense, and we did so in the past already. I explicitly opted into NOT changing the default name Version
This is the default behaviour of Nuxt's Runtime Config. I had lots of struggle to get it working correctly because of all the "magic" it does. The current solution is likely final:
These are actually two of the intended methods and not workarounds. Prior to I think the improvements we should still land:
|
Thanks for your detailed response. I have to add that after writing my last comment, I found out an extra source of confusion, which is that when we modify In the end I concluded that 'workaround' 3.2 of setting baseURL: `${process.env.AUTH_ORIGIN/api/auth` did not actually work. It was only working because my previous change of the
Yeah I am not sure. One point of confusion here for me is that there often is an extra auth server. Like the Keycloak server in my case. So when you say Maybe |
The provider-specific configuration is generally inside the |
Yeah ok.
I missed that you also propose changing I do have one more suggestion / idea.... Currently, my .env NUXT_AUTH_ENDPOINT = http://localhost:3000/api/auth
NUXT_AUTH_SECRET = ....
NUXT_AUTH_ISSUER = http://localhost:8080/realms/my-realm
NUXT_CLIENT_ID = myapp
# NUXT_CLIENT_SECRET = ...
NUXT_SESSION_STRATEGY = 'jwt'
NUXT_SESSION_MAX_AGE = 2592000 # seconds (30 days)
NUXT_SESSION_UPDATE_AGE = 86400 # seconds (24 hours)
NUXT_IDP_LOGOUT = true
NUXT_AUTH_DEBUG = true and I am setting nuxt.config.ts auth: {
originEnvKey: 'NUXT_AUTH_ENDPOINT`,
// ...
} ...so I am effectively renaming But you can maybe see the pattern... I prefixed all env vars with nuxt.config.ts runtimeConfig: {
AUTH_DEBUG: '',
AUTH_ENDPOINT: '',
AUTH_ISSUER: '',
AUTH_SECRET: '',
SESSION_STRATEGY: 'jwt',
SESSION_MAX_AGE: `${30 * 24 * 60 * 60}`, // 30 days
SESSION_UPDATE_AGE: `${24 * 60 * 60}`, // 24 hours
CLIENT_ID: 'myapp',
CLIENT_SECRET: '',
IDP_LOGOUT: 'true',
}, As you can see, the advantage of choosing a name starting with So:
Would maybe be best? |
Unfortunately this idea already came to me and I tested it with no success. There was actually such a change after #848, which got reverted iirc. In a perfect world, you would simply set the default values on runtimeConfig: {
public: {
auth: {
baseURL: 'http://localhost:3000/api/auth'
}
}
} And you'd expect that setting But your suggestion of course makes a lot of sense! |
IIRC, the reason this was not working was that the code that was checking process.env for and the reason for using But I'm not sure so... |
Environment
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
config :
endpoint in ~/server/api/auth/[...].ts
just it is, but when i load the website again ( i don't do anything)
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
The text was updated successfully, but these errors were encountered: