-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
When you call an internal endpoint to set or delete a cookie, this doesn't work if you also throw an error or redirect afterwards.
Reproduction
https://github.com/kevinrenskers/sk-cookie-problem.
When you first open the homepage there is a button to login, it just sets a cookie. Then refresh the website. The cookie should be deleted and then it should redirect, but instead the cookie isn't deleted and that causes an endless redirect loop.
When you remove the throw, the cookie does get deleted. It seems that for some reason the cookie isn't deleted if you throw something as well. Same goes if you throw an error, not only when you throw a redirect.
Logs
No response
System Info
System:
OS: macOS 12.6
CPU: (10) arm64 Apple M1 Max
Memory: 1.34 GB / 32.00 GB
Shell: 3.5.1 - /opt/homebrew/bin/fish
Binaries:
Node: 16.17.0 - ~/Library/pnpm/node
npm: 8.15.0 - ~/Library/pnpm/npm
Browsers:
Safari: 16.0
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.73
@sveltejs/kit: next => 1.0.0-next.481
svelte: ^3.44.0 => 3.50.1
vite: ^3.1.0 => 3.1.0Severity
blocking an upgrade
Additional Information
This is blocking me from handling 401 errors. What I need to do is remove the token cookie and redirect the user back to the safety of the homepage, but I can either delete the cookie or redirect, not both.