繁体   English   中英

从 Angular 9 调用 AWS api 给出 cors 错误

[英]Call to AWS api from Angular 9 giving cors error

我正在 Angular 9 中编写一个 post 方法,它调用 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. 我在我的 AWS API 上启用了 CORS(并部署了它)。 另外,我在我的angular.json proxy.conf.json {

 "/api/*": { "target": "url", "secure": true, "changeOrigin": true }

但我仍然收到}错误。 我已经使用 Postman 测试了我的 POST 请求,并且请求运行完美。 有没有办法解决这个 CORS 错误?

我建议您遵循 AWS 文档上的为 REST API 资源启用 CORS

由于该请求来自 postman,因此我们暗示该问题很可能是客户端问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM