跨域设置
Posted lajiao
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了跨域设置相关的知识,希望对你有一定的参考价值。
# 参考:
https://blog.csdn.net/linzi1994/article/details/82724429
https://www.cnblogs.com/ShaunChen/p/5998800.html
# 配置详解:
# 跨域设置
CORS_ORIGIN_ALLOW_ALL = True # 允许所有域名
CORS_ALLOW_CREDENTIALS = True # 允许获取cookie
CORS_URLS_REGEX = r‘^.*$‘
CORS_ORIGIN_WHITELIST = (
‘*‘
)
#
# CORS_ORIGIN_ALLOW_ALL = False
# CORS_ORIGIN_WHITELIST = (
# ‘localhost:63343‘,
# )
#
# # 默认值是全部:
# CORS_ORIGIN_WHITELIST = () # 或者定义允许的匹配路径正则表达式.
# CORS_ORIGIN_REGEX_WHITELIST = (‘^(https?://)?(w+.)?>google.com$‘, ) # 默认值:
# CORS_ORIGIN_REGEX_WHITELIST = ()
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‘,
)
以上是关于跨域设置的主要内容,如果未能解决你的问题,请参考以下文章