-
-
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
Hosting Next Auth behind a proxy (Cloudflare Worker) - the OAuth "redirect_uri" is incorrectly set #6526
Comments
I found the problem. Next Auth doesn't listen for Here is the solution I used to get around it:
from: #4509 (comment) (thanks to @jjorissen52). |
Thanks, this has come up in #6647 newly, so we might revisit this issue. For context, the intention was not to break proxied deployments, but an observation where people were deploying to Vercel with a wrongly set As you noted, this doesn't really make sense, but seemed to be the solution for most people at the time. We could re-visit #4509 and add this, and document that you only need to add |
@balazsorban44 This issues has Cloudflare worker in the title but addresses a problem in vercel.
This works fine and all /auth calls are proxied to https://api.mydomain.com In the auth config on the api backend the redirectProxyUrl is set to https://www.mydomain.com So most of this seems to work, i get the following cookies in the browser: I am not sure if the callback url is correct though. After that it should redirect to 'www.mydomain.com/welcome after signing but it redirects to 'www.mydomain.com/auth/callback/welcome' . I don't know why that is. I think I have some basic mis-conceptions on the way the @auth/sveltekit works in this case but I cannot fnd a real solution to hiding next-auth behind a proxy using sveltekit in cloudflare pages. Setting NEXTAUTH_URL_INTERNAL or AUTH_URL_INTERNAL to https://api.mydomain.com does not have any effect. Any help would be greatly appreciated. |
Question 💬
frontend.domain.com
(fake domain for privacy reasons) on Vercel.site.domain.com
domain.com
that will proxy some requests tosite.domain.com
and some tofrontend.domain.com
based on the path.My entire application is working correctly except the
redirect_uri
on the OAuth providers. For some reason theredirect_uri
's host is alwaysfrontend.domain.com
.I've scoured previous Next Auth issues and Stackoverflow and have not been able to find a solution that works.
I've tried:
trustHost
optionNEXTAUTH_URL
andNEXTAUTH_URL_INTERNAL
NEXTAUTH_URL=domain.com
NEXTAUTH_URL=domain.com
andNEXTAUTH_URL_INTERNAL=frontend.domain.com
NEXTAUTH_URL=frontend.domain.com
andNEXTAUTH_URL_INTERNAL=domain.com
https://frontend.domain.com/api/auth/callback/linkedin
andhttps://domain.com/api/auth/callback/linkedin
to the "Authorized redirect URLs for your app" in LinkedIn.No matter what I do, the
redirect_uri
's host doesn't change.How to reproduce ☕️
Here is the client request to
domain.com/api/auth/signin/linkedin
fromdomain.com/auth/login
And here is the
/authorization
request to LinkedIn from Next AuthI'd expect when I set
NEXTAUTH_URL
todomain.com
that theredirect_uri
's host should bedomain.com
.Contributing 🙌🏽
Yes, I am willing to help answer this question in a PR
The text was updated successfully, but these errors were encountered: