标签:文件 rsh option red setting enc csr settings token
1. 安装模块django-cors-headerspip3 install django-cors-headers
配置INSTALLED_APPS
INSTALLED_APPS = [
...,
‘corsheaders‘
]
配置中间件, 注意顺序
MIDDLEWARE = [
...,
‘corsheaders.middleware.CorsMiddleware‘,
‘django.middleware.common.CommonMiddleware‘
]
再settings.py文件末尾添加下面内容
‘‘‘
跨域设置
‘‘‘
CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_ALLOW_ALL = True
CORS_ORIGIN_WHITELIST = ()
CORS_ALLOW_METHODS = (
‘DELETE‘,
‘GET‘,
‘OPTIONS‘,
‘PATCH‘,
‘POST‘,
‘PUT‘,
‘VIEW‘,
)
CORS_ALLOW_HEADERS = (
‘accept‘,
‘accept-encoding‘,
‘authorization‘,
‘content-type‘,
‘dnt‘,
‘origin‘,
‘user-agent‘,
‘x-csrftoken‘,
‘x-requested-with‘,
)
标签:文件 rsh option red setting enc csr settings token
原文地址:https://blog.51cto.com/14284354/2480299