API Gateway CORS error

0

I set enable CORS in my API Gateway and deployed it. However, my webpage keeps generating CORS error when it calls API. I think it works well at first. What is the problem?

已提問 2 年前檢視次數 391 次
4 個答案
0

My API is Rest API, and Lambda Proxy integration is checked. Also, I followed "Enable CORS on a resource using the API Gateway console"(https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors-console.html). So I think I don't need more action as "Configure your REST API integrations to return the required CORS header" in your link. However, It still does not work. if there is any mistake in my reaction, please let me know. Additionally, I deployed as well.

已回答 2 年前
0

It works now. Thank you. As result, I did

  1. enable CORS in API Gateway.
  2. set header in response in Lambda return.
已回答 2 年前
0

Please take a look at the following troubleshooting guide from AWS Premium Support - https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-cors-errors/

profile pictureAWS
專家
已回答 2 年前
0

Please take a look at this document - https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html

the following paragraph

Enabling CORS support for Lambda or HTTP proxy integrations For a Lambda proxy integration or HTTP proxy integration, you can still set up the required OPTIONS response headers in API Gateway. However, your backend is responsible for returning the Access-Control-Allow-Origin and Access-Control-Allow-Headers headers, because a proxy integration doesn't return an integration response.

Since you mentioned you are using Proxy integration, is your backend returning these headers.

profile pictureAWS
專家
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南