Skip to content

Commit

Permalink
fix: fix aws api gateway v2 event source cookies handling (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
colonist4 committed May 11, 2021
1 parent 909c514 commit 6e0868c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions jest-helpers/api-gateway-v2-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function makeApiGatewayV2Response (values = {}, {
}
values.headers = convertMultiValueHeadersToHeaders({ multiValueHeaders: values.multiValueHeaders })
delete values.multiValueHeaders
delete values.headers['set-cookie']

if (shouldConvertContentLengthToInt) {
// APIGWV2 returns content-length as a number instead of a string under certain conditions:
Expand Down
6 changes: 4 additions & 2 deletions src/event-sources/aws/api-gateway-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ function getResponseToApiGateway ({
isBase64Encoded
}

if (headers['set-cookie']) {
responseToApiGateway.cookies = headers['set-cookie']
const cookies = headers['set-cookie']
if (cookies) {
responseToApiGateway.cookies = Array.isArray(cookies) ? cookies : [cookies]
delete headers['set-cookie']
}

responseToApiGateway.headers = getCommaDelimitedHeaders({ headersMap: headers })
Expand Down

0 comments on commit 6e0868c

Please sign in to comment.