prazdevs / pinia-plugin-persistedstate

💾 Configurable persistence and rehydration of Pinia stores.
https://prazdevs.github.io/pinia-plugin-persistedstate/
MIT License
2.13k stars 121 forks source link

Global `cookieOptions` are not applied in Nuxt 3 #291

Open rudolfbyker opened 7 months ago

rudolfbyker commented 7 months ago

Describe the bug

When using the exact config from the docs https://prazdevs.github.io/pinia-plugin-persistedstate/frameworks/nuxt-3.html#global-options , where stores use localStorage by default, but some stores are explicitly set to use persist: { storage: persistedState.cookies },, then the cookieOptions seems to be ignored in the stores that use cookies. I still get cookies with Secure:false and SameSite:"None" for those stores.

Reproduction

https://stackblitz.com/edit/github-5b43sb

System Info

Stackblitz

Used Package Manager

npm

Validations

rudolfbyker commented 7 months ago

Workaround: Specify this everywhere:

persistedState.cookiesWithOptions({
  sameSite: "strict",
})

instead of

persistedState.cookies
prazdevs commented 2 months ago

Should be fixed and working in v4

rudolfbyker commented 1 month ago

This does not seem to work in v4 either. See https://stackblitz.com/edit/github-5b43sb-n4cbn9?file=nuxt.config.ts

prazdevs commented 1 week ago

With v4, you dont need the @pinia-plugin-persistedstate/nuxt package, as the nuxt module is included in the base package. You can refer to this https://prazdevs.github.io/pinia-plugin-persistedstate/frameworks/nuxt.html#installation