joostfarla / serverless-cors-plugin

Serverless CORS Plugin - Managing Cross-origin resource sharing (CORS) policies
ISC License
70 stars 15 forks source link

Preflight endpoints not deployed by default #6

Closed Borfswitch closed 8 years ago

Borfswitch commented 8 years ago

The OPTIONS endpoints are not being deployed by default. I figured out by looking at the plugin source code that you need to add a --all flag to the command to get the OPTIONS endpoints to deploy.

joostfarla commented 8 years ago

@Borfswitch thanks for reporting!

This is done intentionally because multiple functions with different HTTP methods can share the same path. The question I was struggling with was: If one of x functions with the same path is being deployed, should it deploy the preflight endpoint for all methods?

Any thoughts on this?

Borfswitch commented 8 years ago

@joostfarla, I think it would be nice if there was some way to specify which endpoints within a function should have CORS enabled, rather than just applying it to all endpoints within a function.

Are there plans to document the usage of the --all flag?

It also might be nice to have something like a --cors flag that would deploy the preflight endpoints only for the function(s) currently being deployed, so that you aren't forced to always use --all.

joostfarla commented 8 years ago

Most edge cases can be solved by making proper use of templates & variables. The use of the --all flag has already been documented , so I will close this issue.