Skip to content

defaultMethodOptions should be selectively applied to CORS OPTIONS method #8615

@whimzyLive

Description

@whimzyLive

Tl;DR

defaultMethodOptions should exclude options method by default or at least have an option to do that.

Read More

LambdaRestApi has defaultMethodOption, when it is specified, it gets applied to all methods for given api resource. which is awesome but doesn't work when CORS is involved.

Take this simple example,
where I want all the methods to require x-api-key api key so I specify

defaultMethodOption: {
  apiKeyRequired: true
}

On top of this I also want CORS to be enabled on all api resources so in LambdaRestApi I also specify this

defaultCorsPreflightOptions : {
  ... cors options 
} 

Because of defaultCorsPreflightOptions an additional method will be created for all my resources to support CORS but because defaultMethodOption applies on all methods, options will also have apiKeyRequired , which it shouldn't.

Environment

  • CLI Version : 1.38
  • Framework Version: 1.38
  • Node.js Version: 12 -->
  • OS :
  • Language (Version): TypeScript (3.8.3) -->

This is 🐛 Bug Report

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-apigatewayRelated to Amazon API GatewaybugThis issue is a bug.effort/smallSmall work item – less than a day of effortin-progressThis issue is being actively worked on.p1

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions