标签:get pat 请求方式 pps 跨域访问 name encoding options origin
pip install django-cors-headers
INSTALLED_APPS = [
‘corsheaders‘,
]
MIDDLEWARE = [
‘corsheaders.middleware.CorsMiddleware‘,
]
# 配置白名单或者全部允许
# 全部允许配置
CORS_ORIGIN_ALLOW_ALL = True
# 白名单配置
CORS_ORIGIN_WHITELIST = (
‘127.0.0.1:8080‘,
‘localhost:8080‘,
)
# 允许cookie
CORS_ALLOW_CREDENTIALS = True # 指明在跨域访问中,后端是否支持对cookie的操作
# 允许的请求方式
CORS_ALLOW_METHODS = (
‘DELETE‘,
‘GET‘,
‘OPTIONS‘,
‘PATCH‘,
‘POST‘,
‘PUT‘,
‘VIEW‘,
)
# 允许的请求头
CORS_ALLOW_HEADERS = (
‘XMLHttpRequest‘,
‘X_FILENAME‘,
‘accept-encoding‘,
‘authorization‘,
‘content-type‘,
‘dnt‘,
‘origin‘,
‘user-agent‘,
‘x-csrftoken‘,
‘x-requested-with‘,
‘Pragma‘,
)
标签:get pat 请求方式 pps 跨域访问 name encoding options origin
原文地址:https://www.cnblogs.com/achai222/p/14001278.html