generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 467
Closed
Labels
Description
Expected Behaviour
An OPTIONS preflight should return all "Access-Control-*" headers.
Current Behaviour
| headers.update(self._cors.to_dict(self.current_event.get_header_value("Origin"))) |
will only fetch "headers" from the event. This will return None in an ALBEvent with multiValueHeaders enabled.
Code snippet
cors = CORSConfig(
allow_origin="*",
allow_credentials=True,
)
app = ALBResolver(cors=cors)Possible Solution
_origin_header = self.current_event.resolved_headers_field.get("origin") # case insensitive?!?
_origin = _origin_header if isinstance(_origin_header, str) else _origin_header.pop(None)
headers.update(self._cors.to_dict(_origin))Steps to Reproduce
curl -X OPTIONS https://xxx.amazonaws.com -H "origin: http://example.com"
... snip
< HTTP/2 204
< server: awselb/2.0
< date: Tue, 14 May 2024 09:06:13 GMT
< access-control-allow-methods: CONNECT,DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT,TRACE
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.12
Packaging format used
Lambda Layers
Debugging logs
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Shipped