You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a reverse proxy, users are redirected to https://localhost:3000 instead of https://app.example.localhost. This may be due to an invalid Set-Cookie value that points to https://localhost:3000 instead of the value in the query param callbackUrl.
Notice we are now at https://localhost:3000/auth/callback/credentials 😕
Expected behavior
I would expect to be redirected to the callbackUrl in the query param on the sign in page (ie. https://app.example.localhost)
The text was updated successfully, but these errors were encountered:
claudiorivera
added
bug
Something isn't working
triage
Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
labels
Mar 25, 2025
The request.nextUrl object for some reason defaults back to localhost even when you're using a different host (or 127.0.0.1 loopback as some services require rather than localhost). I just can't seem to find where it's happening in order to create a PR.
For my own experience, I can see that the callbackUrl cookie is being set as localhost:3000 even when I access via 127.0.0.1 and the callbackUrl being sent to the Spotify provider is being set to the same, which makes it not work. Works fine in production, as Vercel seems to be doing some kind of tomfoolery to update those parameters based on the comments to the issues above.
Also running into a similar issue for a NextJS 15 preview deployment to vercel. For some reason trustHost is not being respected.
My guess is nextauthjs needs to be updated to work with headers and cookies from next/headers in NextJS 15. Those function are synchronous in NextJS 14 but asynchronous in NextJS 15.
Environment
Reproduction URL
https://github.com/claudiorivera/next-auth-callbackurl
Describe the issue
When using a reverse proxy, users are redirected to
https://localhost:3000
instead ofhttps://app.example.localhost
. This may be due to an invalidSet-Cookie
value that points tohttps://localhost:3000
instead of the value in the query paramcallbackUrl
.Possibly related to #10928
How to reproduce
app.example.localhost
to your/etc/hosts
pnpm i
npx auth secret
caddy run
or use any tool to reverse proxyapp.example.localhost
to port 3000pnpm dev
Set-Cookie
response header:Sign In
callbackUrl
query param ishttps%3A%2F%2Fapp.example.localhost%2F
Set-Cookie
response header:username
andpassword
)https://localhost:3000/auth/callback/credentials
😕Expected behavior
I would expect to be redirected to the
callbackUrl
in the query param on the sign in page (ie.https://app.example.localhost
)The text was updated successfully, but these errors were encountered: