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
fix(core): use NEXTAUTH_URL when getting the url during initialization #10571
base: v4
Are you sure you want to change the base?
Conversation
Signed-off-by: Branden Cash <branden.cash@parchment.com>
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hey thanks for your interest! However, we'd like to avoid making changes like this to v4 atm. Does setting |
No...that just makes things worse. Doing that makes it so that all the other calls that it makes (i.e. It is also explained the documentation that if you are using a custom base path that you set this to the full path to the next auth endpoints. |
@ammmze okay gotcha, yeah we changed the default behaviour of that in v5 but I couldn't remember how v4 behaved in detail. Okay let me have a think abuot this, because changing this now will almost certainly break other peoples existing setups.. 🤔 |
@ndom91 I can make the change a little more involved if we want by changing the behavior of parse-url so that it still uses the protocol and hostname of the given url (the origin) but then also parses the The current proposed fix would always result in the |
For clarity in the proposed alternative solution, i've implemented it on a separate branch found here. Effectively it just makes it so that the |
Oye...as I continue to dig at this I have made another discovery... Previously I had assumed the request "origin" would never have a path*. However, apparently we override the So I see 2 issues here:
But I guess the good news is I think I am now un-blocked from this issue by removing the Note *
|
I have a similar issue, that leads me to be constantly redirected back to my sign-in page or my local host. My production environment is a docker swarm, with caddy infront of it. It works locally, but not in my prod. |
I have the very same issue. Cannot use either signIn() or signOut(). I need signOut() to implement the logout |
☕️ Reasoning
When using an oauth based authentication process and the app is configured with a
basePath
, we need to set theNEXTAUTH_URL
environment variable to tell next-auth / auth.js the base authentication path. However, it does not seem to respect it in all scenarios. For example, I am running next-auth v4.24.7 with a basePath configured as/sso
and aNEXTAUTH_URL=http://localhost:3000/sso/api/auth
. When I perform asignIn('keycloak')
, it does send me to my auth provider (keycloak) BUT theredirect_uri
gets set tohttp://localhost:3000/api/auth/callback
(note the missing/sso
base path).🧢 Checklist
Documentation🎫 Affected issues
I think this fixes the following issues (at least for users using v4...sounds like the v5 beta stuff has this issue too):
📌 Resources