Bug: Invalid CORS origin header sent with sam local start-api
#7848
Labels
stage/needs-investigation
Requires a deeper investigation
sam local start-api
#7848
Description:
When a browser makes a request to a service I have running locally using
sam local start-api
and I have theCors
property configured for theAWS::Serverless::Api
resource, the local service sends the exact value ofCors.AllowOrigin
(which is required to be in this"'http://localhost:3000, https://someservice.dev'"
format) as theAccess-Control-Allow-Origin
header, which the browser (Chrome in this case) reports as an invalid value:My function code returns these exact headers with every response:
which are being used with the deployed service, because my live service returns
"Access-Control-Allow-Origin": "*"
instead of the multi-value one.Steps to reproduce:
SAM template:
Python function that returns this http response:
Build and run:
sam build --parallel sam local start-api --port 8080
Make an appropriate request to
http://127.0.0.1:8080/sentry
from the browser.Observed result:
The request results in status 200, but the browser console shows the errors:
Expected result:
The
Access-Control-Allow-Origin
header should reflect the same as the live service ("Access-Control-Allow-Origin": "*"
in this case), which would prevent the errors in the browser.Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Output of
sam --info
:The text was updated successfully, but these errors were encountered: