繁体   English   中英

AWS API 网关:CORS 和空事件 Object

[英]AWS API Gateway : CORS and Empty Event Object

我一直在努力设置 AWS API 网关以将查询字符串参数传递给我的 Lambda function。

如果我设置为 API 以使用 Lambda 代理集成,我会在 Web 客户端收到 CORS 错误

[index.html:1 Access to XMLHttpRequest at 'https://g2kza1o79f.execute-api.eu-west-2.amazonaws.com/prod/gettest8' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.]

( - 即使我设置了 API 并启用了 CORS。

If I set the API to not use Lambda proxy integration, and CORS enabled, the API call works (no CORS error), but the event object received in my Lambda function is empty( hence no query string parameters). 在这两种情况下,我都使用 GET 方法。 我可以在方法响应 Header 中看到存在 Access-Control-Allow-Origin 选项,但无法访问集成响应

问题:如何设置我的 API 以将查询字符串参数传递到我的 Lambda function 而不会出现 CORS 错误? 我还想为其他 Lambda 函数的 POST 请求设置 API。

我相信它与 First Enable CORS Then Deploy API 有关。

可以在这里找到一个好的线程。 API 网关 CORS:没有“访问控制允许来源”header

暂无
暂无

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

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