浏览代码

允许cors跨源请求

yf_fyh 2 年之前
父节点
当前提交
d9b3373e1a
共有 2 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      bigdataAPI/settings.py
  2. 二进制
      requirements.txt

+ 6 - 0
bigdataAPI/settings.py

@@ -36,9 +36,14 @@ CONFIG = json.loads(config_data)
 
 ALLOWED_HOSTS = ['*']
 
+CORS_ORIGIN_ALLOW_ALL = True
+CORS_ALLOW_CREDENTIALS = True
+CORS_ALLOW_ALL_ORIGINS = True
+
 # Application definition
 
 INSTALLED_APPS = [
+    'corsheaders',
     'django.contrib.admin',
     'django.contrib.auth',
     'django.contrib.contenttypes',
@@ -57,6 +62,7 @@ INSTALLED_APPS = [
 MIDDLEWARE = [
     'django.middleware.security.SecurityMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
+    'corsheaders.middleware.CorsMiddleware',
     'django.middleware.common.CommonMiddleware',
     # 'django.middleware.csrf.CsrfViewMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',

二进制
requirements.txt