lambda function CORS controlled by environment variable

This commit is contained in:
Brandon Liu
2022-07-28 12:37:50 +08:00
parent 62180fa1c7
commit 0557f0e23c

View File

@@ -79,9 +79,11 @@ def lambda_handler(event, context):
headers = {
"Content-Type": "application/protobuf",
"Access-Control-Allow-Origin": "*",
}
if "CORS" in os.environ:
headers["Access-Control-Allow-Origin"] = os.environ.get("CORS")
if reader.header().metadata.get("compression") == "gzip":
if is_api_gateway:
# API Gateway requires a compressed response to correctly return binary data