diff options
author | 2023-02-21 14:18:17 +0100 | |
---|---|---|
committer | 2023-02-21 14:18:17 +0100 | |
commit | 5e26bc891cbebb3598acfa760c135a25c548d624 (patch) | |
tree | 5f254356168eb26da012a445aff403a3cd0e1ea7 /packages/integrations/netlify/src/netlify-functions.ts | |
parent | d3df40af2edeb95afa2f7515119964ef4af09fae (diff) | |
download | astro-5e26bc891cbebb3598acfa760c135a25c548d624.tar.gz astro-5e26bc891cbebb3598acfa760c135a25c548d624.tar.zst astro-5e26bc891cbebb3598acfa760c135a25c548d624.zip |
fix(cookies): Update Undici to 5.20 and fix cookies behaviour (#6323)
* fix(cookies): Update Undici to 5.20 and fix cookies behaviour
* chore: changeset
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 |