Open yutveg opened 8 months ago
Hi
According to the document, I believe if you attach to the root resources all the sub-tree resources should follow this configuration as well. Can you verify that?
I could verify it but it would require a refactor on my part- it seems perhaps the documentation is simply not accurate? In the link you sent me for example it shows the following:
"The following example will enable CORS for all methods and all origins on all resources of the API:"
new apigateway.RestApi(this, 'api', {
defaultCorsPreflightOptions: {
allowOrigins: apigateway.Cors.ALL_ORIGINS,
allowMethods: apigateway.Cors.ALL_METHODS // this is also the default
}
})
I'm not sure if this is a bug or just an issue with the documentation. Thanks for the response, and apologies I don't currently have the time to verify your question.
Describe the bug
I'm instantiating a LambdaRestApi with the
defaultCorsPreflightOptions
property. However, the OPTIONS method that handles the CORS configuration for that property is not automatically being attached to all child resources like the property claims.Expected Behavior
I expected that defining the
defaultCorsPreflightOptions
would apply an OPTIONS method to all child resources of the API instance.Current Behavior
Only the root resource has an OPTIONS method attached to it.
Reproduction Steps
Dependencies:
LambdaRestApi instance:
Possible Solution
No response
Additional Information/Context
I am configuring the API resources/methods/lambda integrations in a nested stack. I can supply the code for that if needed, I'm unsure if it's relevant.
CDK CLI Version
2.101.0
Framework Version
No response
Node.js Version
v18
OS
Linux
Language
TypeScript
Language Version
No response
Other information
No response