簡體   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