Skip to content

Commit

Permalink
Update CSRF_TRUSTED_ORIGINS in settings.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean28518 committed May 7, 2024
1 parent 93c4c23 commit eb2c43f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lac/lac/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,16 @@
"127.0.0.1"
]

CSRF_TRUSTED_ORIGINS = [
'http://localhost',
'http://127.0.0.1',
]


# Add the ip address of the server to the allowed hosts
_ip = os.popen("hostname -I").read().split(" ")[0]
ALLOWED_HOSTS.append(_ip)
CSRF_TRUSTED_ORIGINS.append(f"https://{_ip}")
# Get the domain name in the caddyfile
if os.path.exists("/etc/caddy/Caddyfile"):
with open("/etc/caddy/Caddyfile", "r") as f:
Expand All @@ -45,6 +52,7 @@
for i in range(len(_words)):
if "portal." in _words[i]:
ALLOWED_HOSTS.append(_words[i].replace(";", ""))
CSRF_TRUSTED_ORIGINS.append(f"https://{_words[i].replace(";", "")}")
# Add all hosts from the environment variable separated by a comma
_hosts = os.getenv("ALLOWED_HOSTS", "").split(",")
for host in _hosts:
Expand Down

0 comments on commit eb2c43f

Please sign in to comment.