Skip to content

Commit c6058e1

Browse files
authored
fix(aws-lambda): return outgoing cookies on response objects (#357)
1 parent 6ee3246 commit c6058e1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/runtime/entries/aws-lambda.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ export const handler = async function handler (event: Event, context: Context):
2525
body: event.body // TODO: handle event.isBase64Encoded
2626
})
2727

28+
const outgoingCookies = r.headers['set-cookie']
29+
const cookies = Array.isArray(outgoingCookies) ? outgoingCookies : outgoingCookies?.split(',') || []
30+
2831
return {
32+
cookies,
2933
statusCode: r.status,
3034
headers: normalizeOutgoingHeaders(r.headers),
3135
body: r.body.toString()
@@ -37,5 +41,7 @@ function normalizeIncomingHeaders (headers?: APIGatewayProxyEventHeaders) {
3741
}
3842

3943
function normalizeOutgoingHeaders (headers: Record<string, string | string[] | undefined>) {
40-
return Object.fromEntries(Object.entries(headers).map(([k, v]) => [k, Array.isArray(v) ? v.join(',') : v!]))
44+
return Object.fromEntries(Object.entries(headers)
45+
.filter(([key]) => !['set-cookie'].includes(key))
46+
.map(([k, v]) => [k, Array.isArray(v) ? v.join(',') : v!]))
4147
}

0 commit comments

Comments
 (0)