How to make cookie.get() work with static-adapter after build #8653
-
I'm able to get cookies value locally using cookie.get() method in +layout.sever and +page.server files. But after production build with static-adapter, cookie.get returns undefined even if the cookie can be seen on the browser. Is this an expected behaviour or there's issue with the build? Everything works perfectly locally. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
This is expected behaviour.
With prerendered pages, the only dynamic values are those set in the browser such as during You may want to read the cookie value in the browser (if it isn't http only), or not use |
Beta Was this translation helpful? Give feedback.
This is expected behaviour.
adapter-static
prerenders your pages at build time, so your server functions are only run during build time, and not anymore after that. Hence, your cookie is never read after build.With prerendered pages, the only dynamic values are those set in the browser such as during
onMount
.You may want to read the cookie value in the browser (if it isn't http only), or not use
adapter-static