Skip to content

Commit

Permalink
Finally the Hosts and Extra hosts bit both work
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOriginalSoni committed Oct 30, 2024
1 parent 728010b commit 23d2727
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ DATABASE_URL = ""
HOST_URL = "*"

#If you decide to add multiple websites as whitelisted (for example, domain name shenanigans)
#CSRF_TRUSTED_EXTRA = "https://myus-prod.fly.dev"
CSRF_TRUSTED_EXTRA = ""
#HOSTS_URL_EXTRA = "myus-prod.fly.dev"
HOSTS_URL_EXTRA = ""

17 changes: 12 additions & 5 deletions myus/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,25 @@
DEBUG = False

host_url = os.getenv("HOST_URL")
ALLOWED_HOSTS = [host_url]
extra_hosts_url = os.getenv("HOSTS_URL_EXTRA")

if os.getenv("CSRF_TRUSTED_EXTRA"):
CSRF_TRUSTED_ORIGINS = ["https://" + host_url, os.getenv("CSRF_TRUSTED_EXTRA")]
if extra_hosts_url:
CSRF_TRUSTED_ORIGINS = [
"https://" + host_url,
"https://www." + host_url,
os.getenv("CSRF_TRUSTED_EXTRA"),
"https://" + extra_hosts_url,
]
ALLOWED_HOSTS = [
host_url,
"www." + host_url,
extra_hosts_url,
]
else:
CSRF_TRUSTED_ORIGINS = ["https://" + host_url]
CSRF_TRUSTED_ORIGINS = ["https://" + host_url, "https://www." + host_url]
ALLOWED_HOSTS = [
host_url,
"www." + host_url,
]

# Application definition
INSTALLED_APPS = [
Expand Down

0 comments on commit 23d2727

Please sign in to comment.