NextAuth passes static redirect_uri from provider config during token exchange — not current domain #13095
Unanswered
CodeWizardHemant
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm running into a problem when using NextAuth.js with a custom provider (Duende IdentityServer6) in a multi-subdomain setup (e.g.,
admin.hemant.com
,app.hemant.com
, etc.).🔍 The issue
When using a dynamic provider like this:
...NextAuth still sends the
redirect_uri
from the static provider config (likely fromprovider.callbackUrl
or fallback toNEXTAUTH_URL
) — even though I expected it to be based on the request’s current subdomain (req.headers.host
).🧵 Evidence (code reference)
Looking at the internal code, the token exchange uses:
This means it always uses
callbackUrl
from the static provider config, rather than dynamically resolving it from the request likegetBaseUrl(req)
, even if the provider is defined as a function.This leads to:
invalid_grant
orinvalid_redirect_uri
errors from IdentityServer💬 Questions
redirect_uri
at runtime, just like we can fortoken
,authorization
, anduserinfo
?provider.callbackUrl
or the internal token handler respect the incoming request context (req.headers.host
)?🧪 Setup
*.hemant.com
)Any suggestions would be greatly appreciated. I'm happy to post a minimal repro if needed!
Thanks 🙏
Beta Was this translation helpful? Give feedback.
All reactions