[英]Adding header with value django cores
According to the django-cors-header documentation in order to add custom headers you add:根据django-cors-header文档,为了添加您添加的自定义标头:
CORS_ALLOW_HEADERS = default_headers + ('my-custom-header',)
To your settings.py
, question is how do you add my-custom-header along with it's value to settings.py.对于您的settings.py
,问题是如何将 my-custom-header 及其值添加到 settings.py 中。
CORS_ALLOW_HEADERS
is a list of headers that can be used while making actual request CORS_ALLOW_HEADERS
是在发出实际请求时可以使用的标头列表
Following setting does not set header values that can be used, just headers that can be used in requests以下设置没有设置可以使用的header值,只设置可以在请求中使用的header
Also content-type
is already in default_headers so it doesn't need to be set as extra此外, content-type
已经在 default_headers 中,因此不需要将其设置为额外的
CORS_ALLOW_HEADERS = (
'accept',
'accept-encoding',
'authorization',
'content-type',
'dnt',
'origin',
'user-agent',
'x-csrftoken',
'x-requested-with',
)
To explain more on your comment解释更多关于您的评论
CORS package is used to give a preflight request issued from browser ( OPTIONS method ) answer on questions regarding which/if method or headers are accepted on the following server CORS 包用于给出从浏览器( OPTIONS 方法)发出的预检请求,回答有关以下服务器接受哪个/如果方法或标题的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.