Skip to content

Commit

Permalink
fix: remove undefined values from headers
Browse files Browse the repository at this point in the history
  • Loading branch information
mjad218 committed Oct 31, 2024
1 parent 1f92c58 commit 6a6be4f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ export const buildOutgoingHttpHeaders = (
const res: OutgoingHttpHeaders = {}

const cookies = []
const entries = headers instanceof Headers ? headers.entries() : Object.entries(headers)
const entries =
headers instanceof Headers
? headers.entries()
: Object.entries(headers).filter(([, value]) => value)

for (const [k, v] of entries) {
if (k === 'set-cookie') {
Expand All @@ -56,6 +59,7 @@ export const buildOutgoingHttpHeaders = (
res[k] = v
}
}

if (cookies.length > 0) {
res['set-cookie'] = cookies
}
Expand Down

0 comments on commit 6a6be4f

Please sign in to comment.