-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed as not planned
Closed as not planned
Copy link
Description
Describe the bug
When returning custom Response objecs inside the handle function of the hooks.server file, all interactions with the event.cookies parameter get ignored.
In order to properly set cookies, somewone would need to manually specify them in the headers object.
return new Response(payload, {
headers: {
'set-cookie', event.cookies.serialize('custom', 'value',)
}
})I would expect that cookies are beeing set even if someone returns a custom Response object.
When using events.cookies.set after resolve we will get an error message.
const response = await resolve(event);
// this will throw an error
event.cookies.set('test', 'cookie')
return responseBut I think it makes sense also to support that use case and allow cookies beeing set after the rendering process.
Reproduction
https://github.com/ivanhofer/sveltekit-request-cookie-bug
- start the dev server
- navigate to http://localhost:5173/custom
- see that the
customcookie does not get applied
Logs
No response
System Info
System:
OS: Linux 5.15 Ubuntu 20.04.5 LTS (Focal Fossa)
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-11370H @ 3.30GHz
Memory: 2.08 GB / 7.65 GB
Container: Yes
Shell: 5.8 - /usr/bin/zsh
Binaries:
Node: 16.16.0 - ~/.volta/tools/image/node/16.16.0/bin/node
Yarn: 1.22.17 - ~/.volta/tools/image/yarn/1.22.17/bin/yarn
npm: 8.18.0 - ~/.volta/tools/image/npm/8.18.0/bin/npm
Browsers:
Chrome: 107.0.5304.68
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.87
@sveltejs/kit: next => 1.0.0-next.542
svelte: ^3.44.0 => 3.53.1
vite: ^3.1.0 => 3.2.3Severity
serious, but I can work around it
Additional Information
No response
Metadata
Metadata
Assignees
Labels
No labels