aws / aws/aws-sam-cli

Bug: providing multiple comma-separated CORS origins fails

Open
#9,063 1 comment 1 reaction 0 assignees View on GitHub
stage/needs-triage
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

I am using ` AWS::Serverless::Api`.

Providing multiple origins through the `Cors.AllowOrigin` property results in an invalid `Access-Control-Allow-Origin` header being received by the browser.

The documentation suggests that multiple origins are supported : https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-api-corsconfiguration.html

When i have the following in my template :

```yaml
AllowOrigin: "'http://origin-1,http://origin-2'"
```

The server returns :

```
Access-Control-Allow-Origin: http://origin-1,http://origin-2
```

Which is invalid according to the CORS specification.

SAM needs to return only one origin in the `Access-Control-Allow-Origin` header, namely the one that matches the `Origin` request header.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.