R
Railwayβ€’3mo ago
hus

Successful Auth callback is redirecting to localhost

After successful login, the callback redirects to localhost. I have checked the env variables for redirect multiple times and also updated handleAuth on the call back multiple times but I do not know why or how to update or assign the correct Location field to the call back. I have read previously in the Redirect to Localhost that this is an issue with some form of config or some form of monkey patching but I'm not too sure what the next step forward into fixing this issue would be. Thank you!
No description
Solution:
Resolved this issue, the fix was adding a check in callback/routes.ts to see if the callback auth contains localhost or not, if it does contain localhost, force redirect to application domain πŸ‘
Jump to solution
11 Replies
Percy
Percyβ€’3mo ago
Project ID: 8425b175-2f24-462a-aa98-2ad6fec6c43b
hus
husOPβ€’3mo ago
Project ID: 8425b175-2f24-462a-aa98-2ad6fec6c43b
Brody
Brodyβ€’3mo ago
hosts like vercel would monkeypatch the location header for you, Railway wont, as Railway will only ever run your code as-is. meaning you would need to set the correct redirect URL yourself in your own code or config.
hus
husOPβ€’3mo ago
Where can I access the config? In the Config-as-code section?
Brody
Brodyβ€’3mo ago
this would not have anything to do with railway itself, this is a change your need to make in your code or config
hus
husOPβ€’3mo ago
I don't quite understand, it seems to be taking the path of where the application was deployed on the vps, localhost:8080
No description
hus
husOPβ€’3mo ago
I'm assuming i would have to change this deployment uri or some how telling the deployment to point to the railway domain?
Brody
Brodyβ€’3mo ago
yes you would need to tell your code the correct public url its running on so it can be used in the location header again, nothing specific to the platform, please research how to do this with a nextjs app
hus
husOPβ€’3mo ago
Thank you!
Solution
hus
husβ€’3mo ago
Resolved this issue, the fix was adding a check in callback/routes.ts to see if the callback auth contains localhost or not, if it does contain localhost, force redirect to application domain πŸ‘
Brody
Brodyβ€’3mo ago
awesome, glad you were able to fix!
Want results from more Discord servers?
Add your server