Skip to content

Commit

Permalink
fix(api-gateway-v2-adapter): Change non-standard headers.raw() to hea…
Browse files Browse the repository at this point in the history
…ders.getSetCookie()
  • Loading branch information
gotgenes committed Jun 25, 2024
1 parent 603adda commit b397ffb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
10 changes: 1 addition & 9 deletions src/adapters/api-gateway-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,8 @@ function createRemixHeaders(
async function sendRemixResponse(
nodeResponse: Response
): Promise<APIGatewayProxyStructuredResultV2> {
const cookies: string[] = []

// AWS API Gateway will send back set-cookies outside of response headers.
for (const [key, values] of Object.entries(nodeResponse.headers.raw())) {
if (key.toLowerCase() === 'set-cookie') {
for (const value of values) {
cookies.push(value)
}
}
}
const cookies = nodeResponse.headers.getSetCookie()

if (cookies.length) {
nodeResponse.headers.delete('Set-Cookie')
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"display": "Default",
"compilerOptions": {
"lib": [
"ES2022",
"DOM.Iterable"
"DOM",
"DOM.Iterable",
"ES2022"
],
"module": "commonjs",
"target": "ES2022",
Expand Down

0 comments on commit b397ffb

Please sign in to comment.