On a SvelteKit endpoint, I am setting a cookie with an expiry using the cookie package on NPM. The code is kind of like the following:
export const post = async () => {
const flavor = cookie.serialize('flavor', 'chocolate chip', {
expires: new Date(Date.now() + 1000 * 60)
})
const headers = new Headers()
headers.append('Set-Cookie', flavor)
return new Response(null, {
headers,
})
}
On local environment, everything's dandy (: But in production, the expiry gets split into a different set-cookie header, pictured below:
I am using the Netlify Adapter, and I've found that it seems to split on commas (relevant code below), but this is problematic as the specification for date demands a comma separating the day of the week and everything else.
headers.forEach((value, key) => {
if (key === 'set-cookie') {
m[key] = value.split(', ');
} else {
h[key] = value;
}
});
Am I missing something with setting cookies, or is this perhaps an unintended side-effect of the adapter?