django-cors-headers not working at all
Solution 1:
Access-Control-Allow-Origin
is included in the response only if origin
header is present in the request.
Browser adds this header automatically, so you shouldn't see CORS errors on the web page that uses your API.
For me this request returned no Access-Control-Allow-Origin
:
curl -v -H "Content-Type: application/json" localhost:80/status
And this one does:
curl -v -H "Content-Type: application/json" -H "origin: *" localhost:80/status
The answer on GitHub page: https://github.com/adamchainz/django-cors-headers/issues/438