Add django cors headers to backend
This commit is contained in:
parent
9faf762224
commit
b699e50754
2 changed files with 11 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
||||||
Django==3.2.8
|
Django==3.2.8
|
||||||
psycopg2-binary>=2.8
|
psycopg2-binary>=2.8
|
||||||
djangorestframework==3.12.4
|
djangorestframework==3.12.4
|
||||||
|
django-cors-headers==3.10.0
|
||||||
|
|
|
@ -39,6 +39,7 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
|
||||||
'rest_framework',
|
'rest_framework',
|
||||||
|
'corsheaders',
|
||||||
|
|
||||||
'right_tree.api',
|
'right_tree.api',
|
||||||
]
|
]
|
||||||
|
@ -51,6 +52,7 @@ MIDDLEWARE = [
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
|
'corsheaders.middleware.CorsMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = 'right_tree.urls'
|
ROOT_URLCONF = 'right_tree.urls'
|
||||||
|
@ -131,3 +133,11 @@ STATIC_URL = '/static/'
|
||||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
|
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
|
||||||
|
CORS_ALLOWED_ORIGINS = [
|
||||||
|
'http://localhost:3000' # Update this for production
|
||||||
|
]
|
||||||
|
|
||||||
|
CORS_ALLOW_HEADERS = [
|
||||||
|
'access-control-allow-origin'
|
||||||
|
]
|
||||||
|
|
Loading…
Reference in a new issue