According to the django-cors-header documentation in order to add custom headers you add:
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.
CORS_ALLOW_HEADERS
is a list of headers that can be used while making actual request
Following setting does not set header values that can be used, just headers that can be used in requests
Also content-type
is already in default_headers so it doesn't need to be set as extra
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.