-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Add CORS support (Serverless v1) #1586
Copy link
Copy link
Closed
Milestone
Description
Feature Request:
I'd like to enable CORS support for API Gateway endpoints in Serverless v1. A schema example could look like this:
functions:
user:
handler: handler.user
events:
- http:
method: post
cors: true
custom:
cors:
allow-origin: '*'
allow-headers:
- Content-Type
- X-Amz-Date
- Authorization
- X-Api-Key
allow-methods:
- POST
plugins:
- api-gateway-cors-plugin
When run (with deployment), it will create the OPTIONS method and the appropriate 200 responses for specified methods, adding the specified origin and headers. Headers, Methods and Origin are required headers by API Gateway, so I reckon a warning should be printed letting the user know what they need to specify. It could also display other validation warnings, such as having wildcard (*) header/origin settings, or if a setting isn't supported by API Gateway, etc., though it would probably be good to have an option to suppress warnings for specific stages.
Benefits:
- It will enable easier development of single page apps.
- We can have CORS support for API Gateway. Yay!
Drawbacks:
- None that I can think of...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels