-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
VERCEL env causes signinUrl and others to be prefixed with https in local development #7202
Comments
I have had this issue before. |
I know in SvelteKitAuth, which is just this project being wrapped for sveltekit, there is an option called |
It may also be that Vercel is changing around the links by itself without your knowledge, keep an eye out for that. |
Thanks for your hints! However I don't think it's related to As soon as this is set, the It doesn't even matter which value |
Looks like this may hold an answer: |
It's not related. This is really about the use of Sorry if it wasn't clear earlier: I work at Vercel and I'll get this sorted internally too :) |
I am having the same issue @dferber90 . Is there a workaround? |
From what I can see it looks like this code uses that env variable to determine if to use secure cookies:
|
That is what I was thinking about before when I looked through the code, but @dferber90 said that it wasn't related to secureCookies, so the issue is probably not a result of that code. |
The workaround I used was to comment out the @Crazypersonalph I was trying to say that it's not related to any cookies I already have, but the error is definitely somewhere in the logic of how next-auth detects whether to use https or not. |
I have an idea. |
I found the issue and created an experimental release with a fix, if anyone wants to test #7214 (comment) TLDR; we need to respect the VERCEL=0 did not help BTW because env variables are always read as strings, and we do not parse the variable to int, so only removing/commenting out would have worked. |
It is safe to say that this issue can now be closed. |
This should be released in |
Hey @balazsorban44 There is a case where respecting x-forwarded-proto it not true. When using Zones the url returned would be wrong and would cause multiple issue.
The desired url might be https://mydomain/app2/auth/.... Please notice the subdomain and basePath NOTES:
Would love to discuss a solution for this issue and maybe create a example project to showcase the issue |
This is the only thing that worked for me... Was banging my head against the wall. Thanks! Would love an actual fix tho |
We are still having this issue. Finally figured it out and commented
|
@dferber90 @balazsorban44 @leogilmour There is a more convenient workaround I just tested, to be able to still use A fix on nextauth side is still needed IMO because this shouldn't be needed. |
I seem to still be having this issue on the latest NEXT_AUTH |
I am having same issue |
I too, am a haver of this issue |
Same here! |
I'm also having the same issue, even after removing Does anyone know a fix for this issue? |
This is what I do currently, but is there a permanent fix? If I |
This is the one that works for me! Thank you! |
Environment
System:
OS: macOS 13.3
CPU: (10) arm64 Apple M1 Pro
Memory: 5.52 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 17.4.0 - ~/Library/Caches/fnm_multishells/16656_1681032588306/bin/node
Yarn: 1.22.15 - ~/Library/Caches/fnm_multishells/16656_1681032588306/bin/yarn
npm: 8.3.1 - ~/Library/Caches/fnm_multishells/16656_1681032588306/bin/npm
Browsers:
Chrome: 112.0.5615.49
Firefox: 111.0.1
Safari: 16.4
Reproduction URL
can be reproduced with next-auth-example by adding VERCEL="1" env var
Describe the issue
next-auth fails if an
VERCEL="1"
env var is present - even if it's set toVERCEL="0"
.I use
vc env pull .env.local
to pull the Vercel defined env vars to my machine.This creates a
VERCEL="1"
env var. But as soon as this is present the sign in no longer works asI get redirected to
https://localhost:3000/api/auth/signin?csrf=true
(notice thehttps
) when trying to sign in.I debugged this and noticed the following: If you open
http://localhost:3000/api/auth/providers
you will see thisNote that
signinUrl
andcallbackUrl
are prefixed withhttps
. This prefix goes away as soon as you remove theVERCEL="1"
env var.How to reproduce
Create a
VERCEL="1"
env var and try to sign in.Next.js version 13.3.0
next-auth version 4.21.1
Expected behavior
Sign in should work. It should not redirect to https locally.
This slightly relates to #4363
The text was updated successfully, but these errors were encountered: