[fix] adapter-netlify: support for multivalue headers
ADD
.changeset/happy-otters-provide.md
+---
+'@sveltejs/adapter-netlify': patch
+---
+
+Use multivalue headers to set multiple cookies

MODIFY
packages/adapter-netlify/files/entry.js
packages/adapter-netlify/files/entry.js
@@ -29,7 +29,7 @@ export async function handler(event) {
return {
isBase64Encoded: false,
statusCode: rendered.status,
- headers: rendered.headers,
+ ...splitHeaders(headers),
body: rendered.body
};
}
@@ -39,3 +39,25 @@ export async function handler(event) {
body: 'Not found'
};
}
+
+/**
+ * Splits headers into two categories: single value and multi value
+ * @param {Record<string, string | string[]>} headers
+ * @returns {{
+ * headers: Record<string, string>,
+ * multiValueHeaders: Record<string, string[]>
+ * }}
+ */
+function splitHeaders(headers) {
+ const h = {};
+ const m = {};
+ for (const key in headers) {
+ const value = headers[key];
+ const target = Array.isArray(value) ? m : h;
+ target[key] = value;
+ }
+ return {
+ headers: h,
+ multiValueHeaders: m
+ };
+}

[fix] adapter-netlify: support for multivalue headers (#1906)