Make Django settings proxy-aware and configurable via environment variables#1
Make Django settings proxy-aware and configurable via environment variables#1pythodoc wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6270593155
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| 'paramount-holidayz-production.up.railway.app' | ||
| 'paramount-holidayz-production.up.railway.app', | ||
| ] | ||
| ALLOWED_HOSTS += [host for host in os.getenv('DJANGO_ALLOWED_HOSTS', '').split(',') if host] |
There was a problem hiding this comment.
Strip whitespace when parsing extra allowed hosts
The added parsing for DJANGO_ALLOWED_HOSTS does not trim whitespace, so a common env value like "example.com, www.example.com" yields " www.example.com" (leading space). Django treats that as a different, invalid host and will return 400 for requests to www.example.com. This only shows up when the env var includes spaces, which is typical in comma-separated lists. Consider stripping each entry before appending.
Useful? React with 👍 / 👎.
Motivation
Description
osand makeDEBUGdriven by theDJANGO_DEBUGenvironment variable viaDEBUG = os.getenv('DJANGO_DEBUG', 'False') == 'True'.DJANGO_ALLOWED_HOSTSenvironment variable by appending parsed values toALLOWED_HOSTS.SECURE_SSL_REDIRECTconfigurable withDJANGO_SECURE_SSL_REDIRECTand addSECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')andUSE_X_FORWARDED_HOST = Trueto support proxy/terminator setups.paramount_holidayz/settings.pyaccordingly.Testing
Codex Task