🧩 Issue: OAuth Redirect URL Error in Production Deployment (Railway)
Description:
I have successfully implemented Chainlit OAuth authentication using Google and GitHub on my local environment — everything works perfectly when running locally.
However, when I deploy the same project on Railway, the OAuth authentication fails with the following error:
redirect_uri_mismatch or “redirect URL incorrect”
This issue occurs despite setting the correct callback URLs in both the Chainlit configuration and the OAuth provider settings.
⚙️ Configuration Details
Local setup (working):
http://localhost:8000/auth/oauth/github/callback
http://localhost:8000/auth/oauth/google/callback
Production setup (failing):
https://afaqulislam-chainlit.up.railway.app/auth/oauth/github/callback
https://afaqulislam-chainlit.up.railway.app/auth/oauth/google/callback
Environment Variables:
OAUTH_GITHUB_CLIENT_ID=xxxxxxxxxxxxxxxxx
OAUTH_GITHUB_CLIENT_SECRET=xxxxxxxxxxxxxxxxx
OAUTH_GOOGLE_CLIENT_ID=xxxxxxxxxxxxxxxxx
OAUTH_GOOGLE_CLIENT_SECRET=xxxxxxxxxxxxxxxxx
CHAINLIT_AUTH_SECRET=xxxxxxxxxxxxxxxxx
🚀 What I’ve Tried
- Verified callback URLs in GitHub Developer Settings and Google Cloud Console — they match exactly.
- Redeployed the app multiple times to ensure environment variables are loaded correctly.
- Tested both domain variations (with and without trailing slashes). * Tried manually updating the
redirect_uri, but the same error persists.
❓Question
Is there any additional configuration required when deploying Chainlit with OAuth on Railway or similar hosting platforms?
For example, do I need to explicitly define a base URL or set an environment variable like CHAINLIT_AUTH_OAUTH_REDIRECT_URL in production?