Skip to content

Commit 3dcaecb

Browse files
authored
fix: add support for trusted CSRF origins so admin forms work again (#108)
1 parent 35ad8ab commit 3dcaecb

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

example.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ DB_PORT=5432
1818
WEBSITE_URL = http://localhost:8000
1919
PASS_RESET_URL_SUFFIX = reset-password/
2020
ACCOUNT_CONFIRMATION_URL_SUFFIX = confirm-email/
21+
22+
# trusted origins
23+
CSRF_TRUSTED_ORIGINS=http://localhost:8000,https://prod-api.unitystation.org,https://dev-api.unitystation.org

src/central_command/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838

3939
ALLOWED_HOSTS = ["*"] if DEBUG else ["localhost", "127.0.0.1"]
4040

41+
_csrf_origins = os.environ.get("CSRF_TRUSTED_ORIGINS", "")
42+
CSRF_TRUSTED_ORIGINS = [origin.strip() for origin in _csrf_origins.split(",") if origin.strip()]
43+
4144
INSTALLED_APPS = [
4245
"django.contrib.admin",
4346
"django.contrib.auth",

0 commit comments

Comments
 (0)