I am writing a post method in Angular 9 which calls an AWS API. However, when I call the post function in Angular 9 : this.http.post(url, body, requestOptions)
, in my browser I get the following error: Access to XMLHttpRequest at 'url' as been blocked by CORS policy: Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response.
I have enabled CORS on my AWS API (and deployed it). Also, I have include the following proxy.conf.json
in my angular.json
:
{
"/api/*": {
"target": "url",
"secure": true,
"changeOrigin": true
}
} but I am still getting the cors error. I have tested my POST request using Postman, and the request runs perfectly. Is there a way to resolve this CORS error?