question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[aws-apigatewayv2] HttpMethod.ANY throws error in deployment when specifying AllowedMethods of CORS configuration

See original GitHub issue

When setting up an HttpApi from api-gatewayv2, you can specify in corsPreflight param the allowed HTTP methods for CORS. This requires to specify an array of supported HTTP methods from enum HttpMethod.

With code example listed below, cdk deploy throws an error saying Method ANY is not supported when deploying the stack.

Reproduction Steps

  1. cdk init sample project
  2. Declare HttpApi via code snippet below
  3. run cdk deploy --trace --verbose
  4. Inspect trace
import * as apiv2 from "@aws-cdk/aws-apigatewayv2";

const api = new apiv2.HttpApi(this, "SimpleApi", {
      corsPreflight:{
        allowHeaders: ["authorization", "x-id-token", "content-type"],
        allowOrigins: ["http://localhost:3000",],
        allowMethods: [HttpMethod.ANY],
        allowCredentials: false
      }
})

What did you expect to happen?

Support HttpMethod.ANY from enum HttpMethod, when setting AllowMethods in corsPreflight param of HttpApi.

What actually happened?

Deploy Trace:

...
 | CREATE_FAILED        | AWS::ApiGatewayV2::Api                    | HttpApi/SimpleApi (HttpApiSimpleApiF9EF49E2) Method ANY is not supported (Service: AmazonApiGatewayV2; Status Code: 400; Error Code: BadRequestException; Request ID: XXXXXXXXXXXXXXXXX; Proxy: null)
...

Environment

  • CLI Version : 1.62.0
  • Framework Version:
  • Node.js Version: v14.8.0
  • OS : Linux Mint 20 Ulyana
  • Language (Version): TypeScript 4.0.2

Other


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nija-atcommented, Feb 25, 2021

@lorenzo2897 - I’ve opened a separate issue to track this - https://github.com/aws/aws-cdk/issues/13280

0reactions
github-actions[bot]commented, Feb 25, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring CORS for an HTTP API - Amazon API Gateway
If you configure CORS for an API, API Gateway ignores CORS headers returned from your backend integration. You can specify the following parameters...
Read more >
HTTP API (API Gateway v2) - Serverless Framework
With HTTP API we may configure CORS headers that'll be effective for all configured endpoints. Default CORS configuration can be turned on with:...
Read more >
The ultimate guide to enabling Cross-Origin Resource ...
If the HTTP method of your request is not present in this list of allowed methods, it will result in a CORS error....
Read more >
How do I resolve a CORS error for my API Gateway REST API?
We appreciate your feedback: https://amazonintna.qualtrics.com/jfe/form/SV_a5xC6bFzTcMv35sSkip directly to the demo: 0:40For more details ...
Read more >
CrossOrigin and CORS in RESTful Web Service
In this short tutorial, I am going to share with you how to enable CrossOrigin in a RESTful Web Service API built with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found