Browse Source

try to fix cors

ilya_shyian 1 year ago
parent
commit
dbe9032059
2 changed files with 4 additions and 0 deletions
  1. 1 0
      requirements.txt
  2. 3 0
      store_back/settings.py

+ 1 - 0
requirements.txt

@@ -1,6 +1,7 @@
 aniso8601==7.0.0
 asgiref==3.5.1
 Django==4.0.4
+django-cors-headers==3.13.0
 django-graphql-jwt==0.3.4
 djangorestframework==3.13.1
 djangorestframework-simplejwt==5.1.0

+ 3 - 0
store_back/settings.py

@@ -22,6 +22,7 @@ try:
 except:
     DEBUG = True
 
+CORS_ORIGIN_ALLOW_ALL = True
 
 
 
@@ -46,6 +47,7 @@ INSTALLED_APPS = [
     'django.contrib.staticfiles',
     'rest_framework',
     'graphene_django',
+    'corsheaders',
     'goods.apps.GoodsConfig',
     'authAPI.apps.AuthAPIConfig',
     'orders.apps.OrdersConfig',
@@ -56,6 +58,7 @@ MIDDLEWARE = [
     'django.middleware.security.SecurityMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
     'django.middleware.common.CommonMiddleware',
+    'corsheaders.middleware.CorsMiddleware',
     # 'django.middleware.csrf.CsrfViewMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',