Skip to content

apigateway: add explicit support for CORS #906

@eladb

Description

@eladb

Requirements

  • resource.addCorsPreflight(options)
  • AllowOrigin
  • AllowHeaders with defaults for API Gateway
  • AllowMethods
  • AllowCredentials
  • MaxAge
  • ExposeHeaders
  • Conditional Vary response header
  • Configure response status code (should default to 204)
  • Support proxy and non-proxy resources
  • Support multiple origins through velocity templates (like in serverless framework).
  • Automatically discover allowed methods by default based on model.
  • Recursive (apply to all child resources)
  • LambdaRestApi (apply a CORS policy to all routes)
  • CORS with custom authorizers (good post) through AWS::ApiGateway::GatewayResponse

Nice to Have

  • Dynamic CORS handler? (through a Lambda proxy and Access-Control-Max-Age=0)

Non-Requirements

Resources

Notes

Coming from stack overflow

Note that we get a lot of confusion around this since it only configures the Preflight request. Customers expect it to be a magic setting for enabling CORS headers on their Lambda responses. We cant do this because API Gateway does not allow response header mapping for Lambda proxy. Might be better to call this CorsPreflight? At minimum document it clearly.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions