CORS

Brightcells 7 anos atrás
pai
commit
6907965f66
2 arquivos alterados com 11 adições e 0 exclusões
  1. 10 0
      kodo/settings.py
  2. 1 0
      requirements.txt

+ 10 - 0
kodo/settings.py

@@ -48,6 +48,7 @@ INSTALLED_APPS = (
48 48
     'django_admin',
49 49
     'django_rlog',
50 50
     'django_we',
51
+    'corsheaders',
51 52
     'api',
52 53
     'account',
53 54
     'box',
@@ -71,6 +72,7 @@ INSTALLED_APPS += ('multidomain', )
71 72
 
72 73
 MIDDLEWARE_CLASSES = (
73 74
     'django.contrib.sessions.middleware.SessionMiddleware',
75
+    'corsheaders.middleware.CorsMiddleware',
74 76
     'django.middleware.common.CommonMiddleware',
75 77
     # 'django.middleware.csrf.CsrfViewMiddleware',
76 78
     'django.contrib.auth.middleware.AuthenticationMiddleware',
@@ -325,6 +327,14 @@ LOGIT_RES_FLAG = True
325 327
 MAKE_PASSWORD_SALT = ''
326 328
 MAKE_PASSWORD_HASHER = ''
327 329
 
330
+# CORS
331
+# CORS_ORIGIN_ALLOW_ALL = True
332
+CORS_ALLOW_CREDENTIALS = True
333
+CORS_ORIGIN_WHITELIST = (
334
+    'localhost:8000',
335
+    '127.0.0.1:8000'
336
+)
337
+
328 338
 # 错误信息邮件设置
329 339
 # Email address that error messages come from.
330 340
 SERVER_EMAIL = 'kimi@pai.ai'

+ 1 - 0
requirements.txt

@@ -6,6 +6,7 @@ StatusCode==1.0.0
6 6
 TimeConvert==1.4.3
7 7
 cryptography==1.5.2
8 8
 django-admin==1.2.4
9
+django-cors-headers==2.2.0
9 10
 django-curtail-uuid==1.0.4
10 11
 django-detect==1.0.5
11 12
 django-file-md5==1.0.2