Replies: 1 comment 2 replies
-
You might need to configure the |
Beta Was this translation helpful? Give feedback.
2 replies
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.
Uh oh!
There was an error while loading. Please reload this page.
-
OK so I'll start of by saying I know multitenancy is not supported yet.
However, having spent some time going through and reading a bunch of stuff about the multi-tenant issues and workarounds for next-auth I implemented something I believed would work but it seems not to and I have no idea why.
My CDN sets a header,
market
and using that header I'm switching out the value of theNEXTAUTH_REDIRECT
env var at runtime.I'm using Okta's OpenID for auth, but via our own domains.
Live server serves both .uk and .ie on different hostnames pointing to the same backend server.
When we authenticate, all requests go to the same .uk server on a different host
The redirect urls seem to be correctly sending the right data back to the right domains but then I get an error on the .ie domain.
NEXTAUTH_REDIRECT is set by default to .uk
Pseudocode:
So the UK service authenticates correctly. The IE service however...
[hostname].ie/api/auth/callback/okta?code=5...KAwX4&state=CrMcA...tk
Okta redirects back to the above url, which then gives me the error
[next-auth][error][OAUTH_CALLBACK_ERROR] https://next-auth.js.org/errors#oauth_callback_error invalid_grant (The 'redirect_uri' does not match the redirection URI used in the authorization request.)
next-auth then redirects to
[hostname].uk/?callbackUrl=[hostname].uk/?error=OAuthCallback
I'm really confused as to why. Is there something internal that might be
await
ing before reading the value of NEXTAUTH_URL? Is the callback code somehow skipping this specific route, leading to the NEXTAUTH_REDIRECT not being set correctly?Secondly this code seems to be skipping the redirect callback which has specific code to allow
.uk
to recognise.ie
redirects and allow them. That callback isn't the one forwarding the request to the.uk
address, I can't see the/callback/okta?code...
in the logs for that callback at all.Does anyone have any suggestions as for what might be going on or how I could possibly fix this?
Beta Was this translation helpful? Give feedback.
All reactions