Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

326
Visualizações
API Gateway HTTP API CORS

I am using the new API Gateway HTTP which during the configuration enables you to add CORS. So I have set the Access-Control-Allow-Origin Header with the setting *.

However when I make a request using Postman I do not see that header and this i causing my VueJS Axios request to fail.

I previously used a Lambda Proxy Integration and did the following in my Lambda

"headers": { 
            "Access-Control-Allow-Origin": "*" 
        }

However the new HTTP API just does not seem to implement CORS. Maybe I am missing something simple.

--EDITS--

So I have continue to find an answer and came across a blog post from the guys at Serverless who set the following

It’ll ensure following headers:

Access-Control-Allow-Origin: *
Access-Control-Allow-Headers:

Content-Type, X-Amz-Date, Authorization, X-Api-Key, X-Amz-Security-Token, X-Amz-User-Agent
Access-Control-Allow-Methods:

OPTIONS, and all the methods defined in your routes (GET, POST, etc.)

I have tried these and redeployed and still only get the standard headers

Thanks

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

For anyone using HTTP API and the proxy route ANY /{proxy+}

You will need to explicitly define your route methods in order for CORS to work.

enter image description here

Wish this was more explicit in the AWS Docs for Configuring CORS for an HTTP API

Was on a 2 hour call with AWS Support and they looped in one of their senior HTTP API developers, who made this recommendation.

Hopefully this post can save some people some time and effort.

over 4 years ago · Santiago Trujillo Relatório

0

If you have a JWT authorizer and your route accepts ANY requests, your authorizer will reject the OPTIONS request as it doesn't contain an Authorization/Bearer token. To resolve this issue, you need to explicitly point your route to the HTTP request/method you need. E.g. POST

In that case, your authorizer will ignore the OPTIONS request without a JWT and proceed with the required request.

over 4 years ago · Santiago Trujillo Relatório

0

(This is answer just for AWS HTTP api gateway/AWS api gateway v2). I have met the same problem and I asked the AWS support finally. The tricky thing is actually CORS had been already working after we configured it, but I just didn't get how to test it (it's different from AWS REST API ), when test we need to specify the Origin(should be same with your setting:Access-Control-Allow-Origin in cors, like: http://example.com) and the Request method. For example:

curl -v -X GET https://www.xxx.yy/foo/bar/  -H 'Origin:http://example.com' -H 'Access-Control-Request-Method: GET'

Then it would return the CORS header you had set in response header: access-control-allow-origin, access-control-allow-methods, access-control-allow-headers, etc.

I just hope this can save time for who met the similar problem. By the way, I hope AWS can update this test way to offical Document(it's not very useful, but most of people must be saw it before find real answer): https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-cors.html

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda