-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cloudflare adapter] Can't set multiple cookies #2305
Comments
I'm not sure that the Cloudflare adapter changes this. If it did, then it'd probably happen here:
I guess Cloudflare itself does it and the solution would be to make SvelteKit split apart the header into two when setting cookies |
Maybe this can work: /**
* @param {Record<string, string | string[]>} headers
*/
function makeHeaders(headers) {
const result = new Headers();
for (const header in headers) {
const value = headers[header];
if (typeof value === 'string') {
result.set(header, value);
continue;
}
for (const sub of value) {
result.append(header, sub);
}
}
return result;
} |
Thanks @JeanJPNM this works perfectly. I'll be using this as a workaround for now. Reckon this behaviour could be made default? |
Ok, I will make a pull request |
Won't |
Yes, it technically does the same thing, but for some reason it works |
I guess it's because headers takes a bytestring and not a |
Describe the bug
When setting multiple cookies from
hooks
in thehandle
function, I have the following code:When using the node adapter, it correctly uses separate entries in the returned headers for each cookie.
However when running on cloudflare workers, with the cloudflare adapter, the cookies are merged into a single entry:
This results in only one cookie being set.
Reproduction
Return multiple cookies and use the
@sveltejs/adapter-cloudflare-workers
adapterLogs
No response
System Info
Severity
blocking all usage of SvelteKit
Additional Information
No response
The text was updated successfully, but these errors were encountered: