'SvelteKit splits a set-cookie header when expiry is defined

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:

the expiry field is split, with the remainder on a new set-cookie header

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?



Solution 1:[1]

This was a bug that was addressed in this issue.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Auroratide