diff options
Diffstat (limited to 'packages/integrations/netlify/src/netlify-functions.ts')
-rw-r--r-- | packages/integrations/netlify/src/netlify-functions.ts | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/packages/integrations/netlify/src/netlify-functions.ts b/packages/integrations/netlify/src/netlify-functions.ts index 0f9b58158..eb6ed7600 100644 --- a/packages/integrations/netlify/src/netlify-functions.ts +++ b/packages/integrations/netlify/src/netlify-functions.ts @@ -102,34 +102,11 @@ export const createExports = (manifest: SSRManifest, args: Args) => { isBase64Encoded: responseIsBase64Encoded, }; - // Special-case set-cookie which has to be set an different way :/ - // The fetch API does not have a way to get multiples of a single header, but instead concatenates - // them. There are non-standard ways to do it, and node-fetch gives us headers.raw() - // See https://github.com/whatwg/fetch/issues/973 for discussion - if (response.headers.has('set-cookie')) { - if ('raw' in response.headers) { - // Node fetch allows you to get the raw headers, which includes multiples of the same type. - // This is needed because Set-Cookie *must* be called for each cookie, and can't be - // concatenated together. - type HeadersWithRaw = Headers & { - raw: () => Record<string, string[]>; - }; - - const rawPacked = (response.headers as HeadersWithRaw).raw(); - if ('set-cookie' in rawPacked) { - fnResponse.multiValueHeaders = { - 'set-cookie': rawPacked['set-cookie'], - }; - } - } else { - const cookies = response.headers.get('set-cookie'); - - if (cookies) { - fnResponse.multiValueHeaders = { - 'set-cookie': Array.isArray(cookies) ? cookies : splitCookiesString(cookies), - }; - } - } + const cookies = response.headers.get('set-cookie'); + if (cookies) { + fnResponse.multiValueHeaders = { + 'set-cookie': Array.isArray(cookies) ? cookies : splitCookiesString(cookies), + }; } // Apply cookies set via Astro.cookies.set/delete |