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 Respostas
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.

respondido há 2 anos
0

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

  1. enable CORS in API Gateway.
  2. set header in response in Lambda return.
respondido há 2 anos
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
ESPECIALISTA
respondido há 2 anos
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
ESPECIALISTA
respondido há 2 anos

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas