-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
NEXTAUTH_URL gets overwritten on Vercel and it breaks the deployment #6763
Comments
Thanks, this recently came up. See also: #6647 and #3944 (reply in thread) You don't actually need I'll keep this open until we decide if we want to prefer |
Hi @balazsorban44 - thanks so much for the reply! Good to know I can get rid of I've checked the links you've shared, and I totally agree with you - it might break the already deployed apps. That's a very good point indeed, and we should avoid that as much as possible. Even though in my opinion it was a bad decision in the first place, to make it behave in such a different way when deployed, and especially coupling the code with the vendor that code could be deployed to (Vercel) - we have what we have, and should focus on what it's best to do next. Here are my observations. If the majority benefits from the current setup, if for the most of the users it's more beneficial and effortless to allow Vercel config to take precedence over
Let me know what you think. |
Thanks for your agreeable suggestions @maxprilutskiy. My takes:
If we go with the new environment variable, lets decide what we should call it:
|
@ThangHuuVu, that's great news you're considering flipping the behavior in the For this legacy package, I agree env variable would be a good solution, given all the context. I think we could indeed reuse So if you folks believe it's gonna be fine - I'd say let's go for it! 👍 |
I'm voting for And look! There's been a PR for it for a while 🙈 #5679 It has conflicts though and not opened against the Here is the relevant place to add this: next-auth/packages/next-auth/src/utils/detect-host.ts Lines 3 to 7 in c004659
|
@balazsorban44 do you have any idea when this might be released/merged? I have potentially 1.7 million users that would benefit!! 😂 |
@magicspon Sorry to be a blocker, but that's not how OSS works 🙂. You can either use |
This sounds a lot like #4507 😁 |
#6814 has been released, so you can set |
I can confirm that this works 😁 Thank you 🥳 |
Great job everyone! 💪 💪 💪 |
Anybody aware of the issues this has created for allot of users? |
Environment
Reproduction URL
https://vercel.com
Describe the issue
I'm deploying nextjs app with nextauth to Vercel, and
NEXTAUTH_URL
gets overwritten. Usually, it wouldn't be a problem: according to the code I was able to find, next-auth gets the host value from the Vercel's system env variables, uses it, and everything works.However... 👇
How to reproduce
In my case, I'm using zones i.e. proxies, to host one application (the landing) from
/
, and another application (the actual app with auth) from/app
. And in this case, Vercel injects through its env variables not the host user requested, but rather the host the app is deployed at.And it breaks the whole set up.
I was able to fix the issue locally, by using
patch-package
, here's the patch:As you see, I'm adding a condition that prevents the host from being overwritten if the
NEXTAUTH_URL
was set by the user.Expected behavior
I expect
next-auth
to not overwrite the host with value provided by Vercel (or whomever else), whenNEXTAUTH_URL
is explicitly set by the user.The text was updated successfully, but these errors were encountered: