I am trying to get django-allauth and Google login to work in production but it’s not clear to me what I’m doing wrong in my app configuration (or elsewhere). In short, it’s working when I use my original domain, but not with my custom domain.
CURRENT STATE
- My app is deployed on Render, let’s call it example-jobs.onrender.com
- I also have a custom domain configured, let’s call it jobs.example.com
- I’ve created two Google OAuth clients, one for dev and one for prod and configured the client information in settings.py
WHAT HAPPENS RIGHT NOW
In my local environment, Google login works correctly and I’m able to login via the OAuth screen on Google
In production, when I go to example-jobs.onrender.com/accounts/login
(the login screen powered by django-allauth), and click to login to Google, I am redirected to the OAuth screen and it reads: “Choose an account to continue to example-jobs.onrender.com”. It doesn’t seem quite correct since I would expect it to show the name of my OAuth app, but if I select my Google account, it redirects me back to the app, and logs me in successfully
In production, when I go to jobs.example.com/accounts/login
(my custom domain), and click to login to Google, I am redirected to the same OAuth screen that reads: “Choose an account to continue to example-jobs.onrender.com”, which is incorrect since I am coming from jobs.example.com. Selecting my Google account throws an error in the browser:
POST /v3/signin/_/AccountsSignInUi/jserror?script=https%3A%2F%2Fjobs.example.com%2Faccounts%2Fgoogle%2Flogin%2F%3Fprocess%3Dlogin&error=Bc%60https%3A%2F%2Faccounts.google.com%2Fv3%2Fsignin%2F_%2FAccountsSignInUi%2Fbrowserinfo%3Ff.sid%3D4331384148165258233%26bl%3Dboq_identityfrontendauthuiserver_20241103.08_p0%26hl%3Den-US%26_reqid%3D350437%26rt%3Dj%2560404&line=Not%20available HTTP/1.1" 404
I am truly at a loss on what I am doing wrong after scouring the Internet for other mentions of this issue as well as asking my trusty AI copilots. Thank you for any light anyone can shed on this issue!
RELEVANT CONFIGURATION
settings.py
SITE_ID = 1
ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https'
SITE_URL = 'jobs.example.com'
USE_X_FORWARDED_HOST = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
ALLOWED_HOSTS = ['jobs.example.com', 'example-jobs.onrender.com']
CSRF_TRUSTED_ORIGINS = ['https://jobs.example.com', 'https://example-jobs.onrender.com']
Google OAuth client
Authorized JavaScript origins
https://jobs.example.com
https://example-jobs.example.com
Authorized redirect URIs
https://jobs.skip.community/accounts/google/login/callback/
https://example-jobs.onrender.com/accounts/google/login/callback/