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

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

问题描述

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

启用了 CORS,但出现以下错误<块引用>

XMLHttpRequest 无法加载

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

解决方案

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

我想补充一下 Ken 所说的内容,并确保您已经在控制台中以及使用 Postman 或其他非浏览器客户端在部署版本上彻底测试了 API 和资源.我认为 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 上的静态站点 POST 时,AWS API Gateway 端点会出现 CORS 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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