dherault / serverless-offline

Emulate AWS λ and API Gateway locally when developing your Serverless project
MIT License
5.16k stars 794 forks source link

API Gateway REST API - Update CORS cli params to override template values, or allow flag for * origin/headers #1709

Open ekcrisp opened 1 year ago

ekcrisp commented 1 year ago

Feature Request

Per the docs, for REST API gateway "if the endpoint config has CORS set to true, the plugin will use the CLI CORS options for the associated route. Otherwise, no CORS headers will be added." We have a custom header in our CORS configuration which prevents us from using cors: true. In my opinion, if the CLI params corsAllowHeaders and corsAllowOrigin are provided it should override template values for any endpoint with CORS configuration, not just endpoints with cors: true.

If others disagree an additional flag --corsAllowAll which sends * value for all CORS headers will allow serverless offline to support local development when a team has a custom CORS configuration. Perhaps both of these changes should be made.

Expected behavior/code

User values for CLI params corsAllowHeaders corsAllowOrigin should override template values for all endpoints with a CORS config, and/or when user adds --corsAllowAll flag * value is used for all CORS headers on all endpoints (Access-Control-Allow-Headers, Access-Control-Allow-Methods, Access-Control-Allow-Origin, etc).