Enable CORS headers for /api/ endpoint. Also upgrade django to 2.1.7.

This commit is contained in:
Víðir Valberg Guðmundsson 2019-03-14 12:57:27 +01:00
parent 222cb74622
commit e3ff8d876e
2 changed files with 8 additions and 3 deletions

View file

@ -45,6 +45,7 @@ INSTALLED_APPS = [
'graphene_django', 'graphene_django',
'channels', 'channels',
'corsheaders',
'profiles', 'profiles',
'camps', 'camps',
@ -127,6 +128,7 @@ BOOTSTRAP3 = {
'javascript_url': '/static/js/bootstrap.min.js' 'javascript_url': '/static/js/bootstrap.min.js'
} }
MIDDLEWARE = [ MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware', 'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
@ -136,6 +138,9 @@ MIDDLEWARE = [
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
] ]
CORS_ORIGIN_ALLOW_ALL = True
CORS_URLS_REGEX = r'^/api/*$'
if DEBUG: if DEBUG:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
INSTALLED_APPS += [ INSTALLED_APPS += [

View file

@ -1,4 +1,4 @@
Django==2.1.5 Django==2.1.7
channels==2.1.6 channels==2.1.6
channels-redis==2.3.2 channels-redis==2.3.2
@ -16,6 +16,8 @@ django-extensions==2.1.4
django-wkhtmltopdf==3.2.0 django-wkhtmltopdf==3.2.0
django-reversion==3.0.2 django-reversion==3.0.2
django-betterforms==1.2 django-betterforms==1.2
django-cors-headers==2.5.0
django-filter==2.1.0
docopt==0.6.2 docopt==0.6.2
future==0.17.1 future==0.17.1
html5lib==1.0.1 html5lib==1.0.1
@ -37,5 +39,3 @@ venusian==1.2.0
webencodings==0.5.1 webencodings==0.5.1
wrapt==1.11.1 wrapt==1.11.1
graphene-django==2.2.0 graphene-django==2.2.0
django-filter==2.1.0