[Bug?]: Cannot delete cookies during single flight request
Duplicates
- [x] I have searched the existing issues
Latest version
- [x] I have tested the latest version
Current behavior 😯
Right now, cookies set during a single flight request are available on the redirected route, but it doesn't account for setting cookies to an empty string or the max age or expires fields.
Expected behavior 🤔
You should be able to set a cookie to the empty string, as well as fully remove a cookie by setting an appropriate max-age or expires.
Steps to reproduce 🕹
Reproduction https://codesandbox.io/p/devbox/wonderful-sunset-dq8cjl
The cookies and redirects are weird in codesandbox so here is a separate repo
Repo https://github.com/zhengkyl/delete-cookie
Steps:
- Click sign in.
- Click sign out.
- It will redirect to home page and then back immediately.
Context 🔦
I'm trying to redirect users based on their logged in status. The homepage should redirect logged in users to the protected page, and the protected page should directed unauthenticated users to the homepage.
The logout action calls setCookie(), but since cookies are not deleted, it breaks the logout logic. This is due to the current implementation of createSingleFlightHeaders https://github.com/solidjs/solid-start/blob/28e3fc5030b4a4eb06c7e3b17bd17569f4873b14/packages/start/src/runtime/server-handler.ts#L309-L335
Your environment 🌎
"@solidjs/router": "^0.15.1",
"@solidjs/start": "^1.1.3",
"solid-js": "^1.9.3",
"vinxi": "^0.5.3"