1. 程式人生 > >跨域設置

跨域設置

ons ogl www. localhost 正則 cookie file token red


# 參考:
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‘,
)


跨域設置