从 S3 上的静态站点发布时,AWS API Gateway 端点出现 CORS 错误 [英] AWS API Gateway endpoint gives CORS error when POST from static site on S3

查看:9
本文介绍了从 S3 上的静态站点发布时,AWS API Gateway 端点出现 CORS 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个使用无服务器(serverless.com)的 API 端点,我通过 API 网关公开了该端点.尽管我已从

启用 CORS,但我收到以下错误<块引用>

XMLHttpRequest 无法加载

尽管我设置了 origin 标头,但当我使用 Postman 发出请求时,我没有收到任何错误.我该如何解决这个问题?

解决方案

我们现在有一个错误,即对 API 网关的失败请求不会包含适当的 CORS 标头,这会掩盖请求中的实际错误.

我想补充一下 Ken 所说的内容,并确保您已经彻底测试了控制台中的 API 和资源,以及使用 Postman 或其他非浏览器客户端的已部署版本.我预计 API 本身存在问题,并且您的 CORS 配置正确.

I have created an API endpoint with Serverless(serverless.com) which I expose through API Gateway. I'm getting following error though I have enabled CORS from the

XMLHttpRequest cannot load https://xxxxxxxxx.execute-api.us-west-2.amazonaws.com/development/signup. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://yyyyyyyyy.com.s3-website-us-east-1.amazonaws.com' is therefore not allowed access.

I don't get any errors when I use Postman to make requests, despite I have set origin header or not. How can I fix this problem?

解决方案

We have a bug right now where failed requests to API Gateway won't include the appropriate CORS headers, which masks the actual error on the request.

I'd add to what Ken said and make sure you've thoroughly tested the API and resources in the console and also on the deployed version using Postman or some other client that isn't a browser. I expect there is an issue with the API itself and that your CORS configuration is correct.

这篇关于从 S3 上的静态站点发布时,AWS API Gateway 端点出现 CORS 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆