awslabs / aws-lambda-go-api-proxy

lambda-go-api-proxy makes it easy to port APIs written with Go frameworks such as Gin (https://gin-gonic.github.io/gin/ ) to AWS Lambda and Amazon API Gateway.
Apache License 2.0
1.04k stars 197 forks source link

To avoid duplicate response headers, only populate MultiValueHeaders #73

Closed jancona closed 3 years ago

jancona commented 4 years ago

Issue #, if available: None, but I can create one if necessary.

Description of changes: We were seeing duplicated CORS headers in our app, which caused the browser to not allow the connection. The problem appears to be caused by code which puts the response headers in both Headers and MultiValueHeaders. According to the docs:

If you specify values for both headers and multiValueHeaders, API Gateway merges them into a single list. If the same key-value pair is specified in both, only the values from multiValueHeaders will appear in the merged list.

So this may be a Lambda bug. But I can't see any reason to populate both maps and this patch appears to fix the duplicate headers.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

krotscheck commented 4 years ago

Created issue #75 for ya. I have no control over merging this though :(

krotscheck commented 4 years ago

@sapessi - Could we get this merged?