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?

4 Answers
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.

answered 2 years ago
0

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

  1. enable CORS in API Gateway.
  2. set header in response in Lambda return.
answered 2 years ago
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
EXPERT
answered 2 years ago
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
EXPERT
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions