Skip to content

Commit

Permalink
Allow setting CSRF_TRUSTED_ORIGINS from env
Browse files Browse the repository at this point in the history
  • Loading branch information
jodal committed Dec 29, 2024
1 parent 149cc4b commit 7bd862a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/deployment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ this:
.. code-block:: text
DJANGO_SECRET_KEY=replace-this-with-a-long-random-value
DJANGO_DEFAULT_FROM_EMAIL=comics@example.com
DJANGO_CSRF_TRUSTED_ORIGINS=https://comics.example.com
[email protected]
# Sending email, alternative 1: Using a local SMTP server
DJANGO_EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
# Sending email, alternative 2: Using the SendGrid API
SENDGRID_API_KEY=your-sendgrid-api-key
Expand Down
8 changes: 8 additions & 0 deletions src/comics/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@
ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS", default=["*"])


# Security - Cross-Site Request Forgery (CSRF)
#
CSRF_TRUSTED_ORIGINS = env.list(
"DJANGO_CSRF_TRUSTED_ORIGINS",
default=["http://localhost:8000"],
)


# Security - Session
#
# Time the user session cookies will be valid. Default: 1 year
Expand Down

0 comments on commit 7bd862a

Please sign in to comment.