Currently, I am working on implementing a post method in Angular 9 that interacts with an AWS API. However, upon calling the post function in Angular 9:
this.http.post(url, body, requestOptions)
, I encountered an error in my browser stating: Access to XMLHttpRequest at 'url' has been blocked by CORS policy: Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response.
Even after enabling CORS on my AWS API and deploying it, as well as adding the necessary proxy.conf.json
configuration in my angular.json
:
{
"/api/*": {
"target": "url",
"secure": true,
"changeOrigin":true
}
I am still facing the CORS error. Interestingly, when testing my POST request using Postman, everything works perfectly fine. Is there any solution available to resolve this CORS issue?