[Django]-Django Cors Allow Access-Control-Allow-Headers

5👍

From documentation for django-cors-headers on PyPI it looks like you need to set the CORS_ALLOW_HEADERS like so:

CORS_ALLOW_HEADERS = [
    ...
    "Example-Header",
    ...
]

https://pypi.org/project/django-cors-headers/

If you want to dive deeper into CORS here is a thorough documentation: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

3👍

For me CORS_ALLOW_HEADERS didn’t work.

after try couple of things I found out CORS_EXPOSE_HEADERS would work.

CORS_EXPOSE_HEADERS = [
    "my-custom-header",
]

this means now I can set ‘my-custom-header’ (with its value) in response header.

Leave a comment