You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// this will blow up in nuxt SSR because it is not in a component.consttoken=useCookie<string>('userToken',rawEncode)constcookiesStorage={setItem(_key: string,state: string){try{token.value=JSON.parse(state).userToken}catch(err){returnundefined}},getItem(_key: string){try{returnJSON.stringify({userToken: token.value})}catch(err){returnundefined}}}constuseStore=defineStore({// ...persist: {enabled: true,strategies: [{storage: cookiesStorage,paths: ['accessToken']},],}}
It runs before the useStore.
But this is problematic when using with SSR frameworks.
Because SSR frameworks (such as nuxt) relies on useSSRContext to retrieve of information about current request.
Which isn't available outside of component life cycle.
The custom storage is a Object parameter of pinia-plugin-persist
It runs
before
theuseStore
.But this is problematic when using with SSR frameworks.
Because SSR frameworks (such as nuxt) relies on
useSSRContext
to retrieve of information about current request.Which isn't available outside of component life cycle.
My current hack about this is
To delay the deference of getCookiesStorage and prevent it from crash the server.
But that isn't a proper usage at all.
I think this should be changed to (or as an alternative option) a factory function that called during useStore, so it don't cause probelm.
The text was updated successfully, but these errors were encountered: