Auth.js not resolve correct Host (Origin) on redirectUrl, SignIn Page #11331
Unanswered
LordLafayette
asked this question in
Help
Replies: 2 comments 2 replies
-
Additionally I have follow code by this example: https://authjs.dev/getting-started/installation This is provider config
|
Beta Was this translation helpful? Give feedback.
0 replies
-
I have noticed that why it resolve Host correct on redirect to Authorize Endpoint , but wrong at Redeem access_token step after receive authorize_code PS. signIn() method call from route handler, when request not authenticated yet, The middleware detect and redirect to route "/auth/azure-sign-in"
|
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.
-
When incoming request come with different Domain, eg. "fuba.com", Auth.js not reslove with it domain, but will be localhost:3000 instead
On Develop
Using command
yarn dev
Server listening at: http://localhost:3000
Map domain "fubar.com" with IP 127.0.0.1
Request URL > https://fubar.com:3000/api/auth/signin
Problem
On Sign-In Page (/api/auth/signin)
When inspect to the Form, The URL that from will submit sign-in is: http://localhost:3000/api/auth/som-provider, instead of incoming domain (fubar.com) .
At Redeem access_token after get authorizeCode
When signin('provier') call, auth.js to redirect browser agent to AuthorizeEndpoint with redirect_url ( In this step the auth.js reslove domain correctly with "fubar.com").
But when Auth.js try to redeem token from AuthorizeCode, it send "local server host (localhost:3000)" at redirect_url to TokenEndpoint, That cause OP to invalid request.
This problem aslo appear on deployment with self host (yarn build & start) and Docker
Solution
The issue was solved when set
AUTH_URL
= production URL or any host name, But this setting will have limit when try to use application with multiple domain nameBTW, as you have mentioned in Doc (https://authjs.dev/getting-started/deployment#auth_url)
Why it not resolve HOST from request header
host
Thankyou.
On Self Host
yarn build & yarn start
and On Devyarn dev
On Docker
Beta Was this translation helpful? Give feedback.
All reactions