Skip to content

Commit 2389815

Browse files
feat(controller): add CORS headers to api
1 parent c27f260 commit 2389815

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

controller/deis/settings.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
)
103103

104104
MIDDLEWARE_CLASSES = (
105+
'corsheaders.middleware.CorsMiddleware',
105106
'django.middleware.common.CommonMiddleware',
106107
'django.contrib.sessions.middleware.SessionMiddleware',
107108
'django.contrib.auth.middleware.AuthenticationMiddleware',
@@ -141,6 +142,7 @@
141142
'rest_framework',
142143
'rest_framework.authtoken',
143144
'south',
145+
'corsheaders',
144146
# Deis apps
145147
'api',
146148
'web',
@@ -161,6 +163,20 @@
161163

162164
SOUTH_TESTS_MIGRATE = False
163165

166+
CORS_ORIGIN_ALLOW_ALL = True
167+
168+
CORS_ALLOW_HEADERS = (
169+
'content-type',
170+
'accept',
171+
'origin',
172+
'Authentication',
173+
)
174+
175+
CORS_EXPOSE_HEADERS = (
176+
'X_DEIS_VERSION',
177+
'X_DEIS_RELEASE',
178+
)
179+
164180
REST_FRAMEWORK = {
165181
'DEFAULT_MODEL_SERIALIZER_CLASS':
166182
'rest_framework.serializers.ModelSerializer',

controller/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ PyYAML==3.11
1818
redis==2.9.1
1919
static==1.0.2
2020
South==1.0
21+
django-cors-headers==0.13

docs/docs_requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ paramiko==1.14.1
1919
psycopg2==2.5.4
2020
python-etcd==0.3.0
2121
South==1.0
22+
django-cors-headers==0.13
2223

2324
# Deis client requirements
2425
docopt==0.6.2

0 commit comments

Comments
 (0)