When trying to commit a POST request to the django server I get the following error:
Obj:1 Access to XMLHttpRequest at 'http://localhost:8000/api/' from origin
'http://localhost:4200' has been blocked by CORS policy: Request header field
content-type is not allowed by Access-Control-Allow-Headers in preflight response.
This is the code where I make the request:
return this.http.post(url, data,
{headers: new HttpHeaders({
'Content-Type': 'application/json',
'Accept': 'application/json',
'Access-Control-Allow-Headers': 'Content-Type',
})}
)
And this is my django settup for corsheaders:
CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_HEADERS = ["access-control-allow-origin"]
Any insight on the problem and how to improve the question will be thanked