Skip to content

Setting up cors for same endpoint only merges Methods, but not headers and origins #2024

@flomotlik

Description

@flomotlik

This is a Bug Report

Description

When Cors is enabled for multiple endpoints that have the same path the Methods are merged into the one CORS OPTION response, but header or origin config created by the separate http events isn't merged into one OPTION request. Following is an example:

functions:
  blog:
    handler: handler.handler
    events:
      - http:
          path: posts
          method: get
          cors:
            origins:
               - http://example.com
      - http:
          path: posts
          method: post
          cors: 
            origins:
               - http://example2.com
      - http:
          path: posts/{id}
          method: put
          cors:
            headers:
               - TestHeader
      - http:
          path: posts/{id}
          method: delete
          cors:
            headers:
               - TestHeader2

The resulting OPTION CORS request should return both origins and both headers as allowed headers and origins, but it doesn't. This was brought up for methods in #1960 and fixed in #1951 for methods, but not fixed for others.

Similar or dependent issues:

Additional Data

  • _Serverless Framework Version you're using_:
  • _Operating System_:
  • _Stack Trace_:
  • _Provider Error messages_:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions