summaryrefslogtreecommitdiff
path: root/packages/integrations/node/src/createOutgoingHttpHeaders.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/integrations/node/src/createOutgoingHttpHeaders.ts')
-rw-r--r--packages/integrations/node/src/createOutgoingHttpHeaders.ts17
1 files changed, 5 insertions, 12 deletions
diff --git a/packages/integrations/node/src/createOutgoingHttpHeaders.ts b/packages/integrations/node/src/createOutgoingHttpHeaders.ts
index e6c0c0ba4..a2f9b74e8 100644
--- a/packages/integrations/node/src/createOutgoingHttpHeaders.ts
+++ b/packages/integrations/node/src/createOutgoingHttpHeaders.ts
@@ -8,15 +8,12 @@ import type { OutgoingHttpHeaders } from 'node:http';
* @returns NodeJS OutgoingHttpHeaders object with multiple set-cookie handled as an array of values
*/
export const createOutgoingHttpHeaders = (
- webHeaders: Headers | undefined | null
+ headers: Headers | undefined | null
): OutgoingHttpHeaders | undefined => {
- if (!webHeaders) {
+ if (!headers) {
return undefined;
}
-
- // re-type to access Header.getSetCookie()
- const headers = webHeaders as HeadersWithGetSetCookie;
-
+
// at this point, a multi-value'd set-cookie header is invalid (it was concatenated as a single CSV, which is not valid for set-cookie)
const nodeHeaders: OutgoingHttpHeaders = Object.fromEntries(headers.entries());
@@ -26,7 +23,8 @@ export const createOutgoingHttpHeaders = (
// if there is > 1 set-cookie header, we have to fix it to be an array of values
if (headers.has('set-cookie')) {
- const cookieHeaders = headers.getSetCookie();
+ // @ts-expect-error
+ const cookieHeaders = headers.getSetCookie() as string[];
if (cookieHeaders.length > 1) {
// the Headers.entries() API already normalized all header names to lower case so we can safely index this as 'set-cookie'
nodeHeaders['set-cookie'] = cookieHeaders;
@@ -35,8 +33,3 @@ export const createOutgoingHttpHeaders = (
return nodeHeaders;
};
-
-interface HeadersWithGetSetCookie extends Headers {
- // the @astrojs/webapi polyfill makes this available (as of undici@5.19.0), but tsc doesn't pick it up on the built-in Headers type from DOM lib
- getSetCookie(): string[];
-}