defaultMethodOptions should be selectively applied to CORS OPTIONS method
See original GitHub issueTl;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
Issue Analytics
- State:
- Created 3 years ago
- Reactions:23
- Comments:19 (7 by maintainers)
Top Results From Across the Web
interface CorsOptions · AWS CDK
The Access-Control-Allow-Credentials response header tells browsers whether to expose the response to frontend JavaScript code when the request's credentials ...
Read more >ASP.NET Core and CORS Gotchas - Rick Strahl's Web Log
It allows the policy to be reused and be applied selectively. Below I use the explicit policy approach. Register and Define a Policy....
Read more >CORS, Preflight request and OPTIONS Method
First, you need to be aware of the Same-origin Policy. It is a browser built-in mechanism which restricts how a script on one...
Read more >Cross-origin Resource Sharing (CORS)
Configure the CORS Exemption to exempt ORIGIN requests. This will automatically trigger an exemption with OPTIONS as its Valid Method, but it won't...
Read more >CORS - API Gateway - 华为云
Method : Select OPTIONS. CORS: Enabled. Select the Mock backend type. Simple Request. When creating an API that will receive simple requests, ...
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 FreeTop 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
Top GitHub Comments
@asterikx until issue is resolved correctly, you can use cdk escape hatches as also suggested by @nija-at.
For my case I did
This issue has received a significant amount of attention so we are automatically upgrading its priority. A member of the community will see the re-prioritization and provide an update on the issue.