gpt4 book ai didi

django - django 中的 allowed_hosts 和 cors_origin_regex_whitelist 有什么区别?

转载 作者:行者123 更新时间:2023-12-05 05:21:34 26 4
gpt4 key购买 nike

这两个 django 设置有什么区别:

  • ALLOWED_HOSTS

  • CORS_ORIGIN_REGEX_WHITELIST

最佳答案

ALLOWED_HOSTS

A list of strings representing the host/domain names that this Django site can serve. This is a security measure to prevent HTTP Host header attacks, which are possible even under many seemingly-safe web server configurations

CORS_ORIGIN_REGEX_WHITELIST

这实际上是一个期待第三方包的变量django-cors-headers .所以事情是当浏览器通过javascript向另一个域(跨域)发起请求时,浏览器将发送一个OPTIONS。首先请求以了解服务器是否为 allowing通过检查 Access-Control-Allow-Origin 来接受请求的域标题。

注意

还有一些其他 header 也使用此 header ,例如 Access-Control-Allow-Headers

关于django - django 中的 allowed_hosts 和 cors_origin_regex_whitelist 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42667227/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com