Question 💬
- I have an application hosted at
frontend.domain.com (fake domain for privacy reasons) on Vercel.
- I have my website hosted on another provider at
site.domain.com
- I have my root domain running on a Cloudflare worker at
domain.com that will proxy some requests to site.domain.com and some to frontend.domain.com based on the path.
- The frontend application is using Next Auth for authentication with 3 providers (credentials, Google, LinkedIn) - credentials is working fine, the issue is with the OAuth ones (Google and LinkedIn)
My entire application is working correctly except the redirect_uri on the OAuth providers. For some reason the redirect_uri's host is always frontend.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:
- toggling the
trustHost option
- all combinations of
NEXTAUTH_URL and NEXTAUTH_URL_INTERNAL
NEXTAUTH_URL=domain.com
NEXTAUTH_URL=domain.com and NEXTAUTH_URL_INTERNAL=frontend.domain.com
NEXTAUTH_URL=frontend.domain.com and NEXTAUTH_URL_INTERNAL=domain.com
- setting the callbackUrl directly from the client
- I've also added
https://frontend.domain.com/api/auth/callback/linkedin and https://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 from domain.com/auth/login


And here is the /authorization request to LinkedIn from Next Auth


I'd expect when I set NEXTAUTH_URL to domain.com that the redirect_uri's host should be domain.com.
Contributing 🙌🏽
Yes, I am willing to help answer this question in a PR
Question 💬
frontend.domain.com(fake domain for privacy reasons) on Vercel.site.domain.comdomain.comthat will proxy some requests tosite.domain.comand some tofrontend.domain.combased on the path.My entire application is working correctly except the
redirect_urion 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:
trustHostoptionNEXTAUTH_URLandNEXTAUTH_URL_INTERNALNEXTAUTH_URL=domain.comNEXTAUTH_URL=domain.comandNEXTAUTH_URL_INTERNAL=frontend.domain.comNEXTAUTH_URL=frontend.domain.comandNEXTAUTH_URL_INTERNAL=domain.comhttps://frontend.domain.com/api/auth/callback/linkedinandhttps://domain.com/api/auth/callback/linkedinto 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/linkedinfromdomain.com/auth/loginAnd here is the


/authorizationrequest to LinkedIn from Next AuthI'd expect when I set
NEXTAUTH_URLtodomain.comthat theredirect_uri's host should bedomain.com.Contributing 🙌🏽
Yes, I am willing to help answer this question in a PR