Skip to content

Commit fbe64c3

Browse files
committed
Add CORS domain whitelist
1 parent ff5cff7 commit fbe64c3

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

democracylab/settings.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
'django.contrib.sitemaps',
5151
'django.contrib.staticfiles',
5252
'rest_framework',
53+
'corsheaders',
5354
'taggit',
5455
'allauth',
5556
'allauth.account',
@@ -108,6 +109,7 @@
108109
'whitenoise.middleware.WhiteNoiseMiddleware',
109110
'django.contrib.sessions.middleware.SessionMiddleware',
110111
'django.contrib.auth.middleware.AuthenticationMiddleware',
112+
'corsheaders.middleware.CorsMiddleware',
111113
'django.middleware.common.CommonMiddleware',
112114
'django.middleware.csrf.CsrfViewMiddleware',
113115
'django.contrib.messages.middleware.MessageMiddleware',
@@ -380,6 +382,10 @@ def read_connection_config(config):
380382
if CSP_FRAME_SRC is not None:
381383
CSP_FRAME_SRC = ast.literal_eval(CSP_FRAME_SRC)
382384

385+
CORS_ALLOWED_ORIGIN_PATTERNS = os.environ.get('CORS_ALLOWED_ORIGIN_PATTERNS', None)
386+
if CORS_ALLOWED_ORIGIN_PATTERNS is not None:
387+
CORS_ALLOWED_ORIGIN_REGEXES = ast.literal_eval(CORS_ALLOWED_ORIGIN_PATTERNS)
388+
383389
# Internationalization
384390
# https://docs.djangoproject.com/en/1.11/topics/i18n/
385391

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ django-appconf==1.0.2
77
django-autofixture==0.12.1
88
django-compressor==2.1.1
99
django-core==1.4.1
10+
django-cors-headers==3.10.1
1011
django-csp==3.7
1112
django-registration==3.1.2
1213
django-rq==2.4.1

0 commit comments

Comments
 (0)