From c07540709ad1036054afa5a2e59a419005643c66 Mon Sep 17 00:00:00 2001 From: XinNie Date: Thu, 4 Apr 2024 10:53:25 -0500 Subject: [PATCH] CSRF to deployment --- lvlgg_backend/lvlgg_backend/deployment.py | 38 +++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lvlgg_backend/lvlgg_backend/deployment.py b/lvlgg_backend/lvlgg_backend/deployment.py index 62c7461..2870215 100644 --- a/lvlgg_backend/lvlgg_backend/deployment.py +++ b/lvlgg_backend/lvlgg_backend/deployment.py @@ -1,15 +1,16 @@ import os -from .settings import* + +from .settings import * from .settings import BASE_DIR -ALLOWED_HOSTS = [os.environ['WEBSITE_HOSTNAME']] -CSRF_TRUSTED_ORIGINS = ['https://' + os.environ['WEBSITE_HOSTNAME']] +ALLOWED_HOSTS = [os.environ["WEBSITE_HOSTNAME"]] +CSRF_TRUSTED_ORIGINS = ["https://" + os.environ["WEBSITE_HOSTNAME"]] DEBUG = False -SECRET_KEY = os.environ['MY_SECRET_KEY'] +SECRET_KEY = os.environ["MY_SECRET_KEY"] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", - "whitenoise.middleware.WhiteNoiseMiddleware", + "whitenoise.middleware.WhiteNoiseMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "corsheaders.middleware.CorsMiddleware", "django.middleware.common.CommonMiddleware", @@ -19,28 +20,27 @@ "django.middleware.clickjacking.XFrameOptionsMiddleware", ] -CORS_ALLOWED_ORIGINS = ['https://delightful-grass-08a6ea310.5.azurestaticapps.net'] +CORS_ALLOWED_ORIGINS = ["https://delightful-grass-08a6ea310.5.azurestaticapps.net"] +CSRF_TRUSTED_ORIGINS = ["https://delightful-grass-08a6ea310.5.azurestaticapps.net"] STORAGES = { - "default": { - "BACKEND": "django.core.files.storage.FileSystemStorage" - }, - "staticfiles": { - "BACKEND": "whitenoise.storage.CompressedStaticFilesStorage" - } + "default": {"BACKEND": "django.core.files.storage.FileSystemStorage"}, + "staticfiles": {"BACKEND": "whitenoise.storage.CompressedStaticFilesStorage"}, } -CONNECTION = os.environ['AZURE_POSTGRESQL_CONNECTIONSTRING'] -CONNECTION_STR = {pair.split('=')[0]:pair.split('=')[1] for pair in CONNECTION.split(' ')} +CONNECTION = os.environ["AZURE_POSTGRESQL_CONNECTIONSTRING"] +CONNECTION_STR = { + pair.split("=")[0]: pair.split("=")[1] for pair in CONNECTION.split(" ") +} DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql", - "NAME": CONNECTION_STR['dbname'], - "HOST": CONNECTION_STR['host'], - "USER": CONNECTION_STR['user'], - "PASSWORD": CONNECTION_STR['password'], + "NAME": CONNECTION_STR["dbname"], + "HOST": CONNECTION_STR["host"], + "USER": CONNECTION_STR["user"], + "PASSWORD": CONNECTION_STR["password"], } } -STATIC_ROOT = BASE_DIR/'staticfiles' \ No newline at end of file +STATIC_ROOT = BASE_DIR / "staticfiles"