From 0a511e53e91a26ce1229b35e8dd93758dec63638 Mon Sep 17 00:00:00 2001 From: rkun123 Date: Wed, 7 Jul 2021 07:41:35 +0000 Subject: [PATCH] [update] CORS header support --- server/server/settings/base.py | 14 ++++++++------ server/server/settings/development.py | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/server/server/settings/base.py b/server/server/settings/base.py index 7b41f79..58ef714 100644 --- a/server/server/settings/base.py +++ b/server/server/settings/base.py @@ -32,15 +32,16 @@ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'corsheaders', 'colorfield', 'works', 'storages', - 'corsheaders', 'rest_framework' ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', + 'corsheaders.middleware.CorsMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', @@ -127,6 +128,11 @@ }, ] +CORS_ALLOWED_ORIGINS = [ + 'https://shared-vps.compositecomputer.club', + 'http://localhost:3000' +] + # Internationalization # https://docs.djangoproject.com/en/3.0/topics/i18n/ @@ -151,8 +157,4 @@ STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' MEDIA_ROOT = os.path.join(BASE_DIR, "media") -MEDIA_URL = '/media/' - -CORS_ALLOWED_ORIGINS = [ - 'http://*' -] \ No newline at end of file +MEDIA_URL = '/media/' \ No newline at end of file diff --git a/server/server/settings/development.py b/server/server/settings/development.py index 446efa1..167c356 100644 --- a/server/server/settings/development.py +++ b/server/server/settings/development.py @@ -21,6 +21,7 @@ ALLOWED_HOSTS = ["*"] +CORS_ALLOW_ALL_ORIGINS = True # Database # https://docs.djangoproject.com/en/3.0/ref/settings/#databases