solid-primitives icon indicating copy to clipboard operation
solid-primitives copied to clipboard

[storage] make it clear that a cookie cannot be set server-side or fix that it cannot be set server-side

Open apatrida opened this issue 1 year ago • 1 comments

Describe the bug

When creating a cookie using makePersistent, you cannot set the cookie server-side in any way. There is no way to cause the code to set the cookie to be invoked in any way. This is not documented. So cookies must be set client, and can be read server, but not set on the server.

Maybe is due to signals not firing during SSR or fetch events, therefore nothing hears the change in the signal to write the header? And there is no work around to use the same storage to manually write the cookie on the server, you would have to implement it completely independently of the code.

no reproducible case as this can't be shown via stackblitz, no?

Minimal Reproduction Link

https://stackblitz.com/github/solidjs/templates/tree/master/ts?file=src%2Findex.tsx

apatrida avatar Apr 29 '24 14:04 apatrida

It works out of the box in solid-start in SSR. In other SSR modes, you have to add the getRequestHeaders and getResponseHeaders functions in the options, since classic solid SSR can run on any server and we cannot know which one it will be.

atk avatar Apr 30 '24 03:04 atk