[aws-apigatewayv2] HttpMethod.ANY throws error in deployment when specifying AllowedMethods of CORS configuration
See original GitHub issueWhen 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
- cdk init sample project
- Declare HttpApi via code snippet below
- run
cdk deploy --trace --verbose
- 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:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@lorenzo2897 - I’ve opened a separate issue to track this - https://github.com/aws/aws-cdk/issues/13280
⚠️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.