robinvdvleuten / vuex-persistedstate

💾 Persist and rehydrate your Vuex state between page reloads.
https://npm.im/vuex-persistedstate
MIT License
5.76k stars 375 forks source link

Add string type of header check #402

Open iliapisaniy opened 3 years ago

iliapisaniy commented 3 years ago

What: Bug in case of using nuxt ssr plugin from readme

Why:

How: Check type of cookie header and set to string if not

Checklist:

Issue #398

Wils3B commented 3 years ago

I Approve, It works

robinvdvleuten commented 3 years ago

Can you explain what you are trying to achieve here?

davidrf88 commented 2 years ago

when using it in conjuction with the cookie package in a project with nuxt ssr the first time it runs the plugin mentioned in the readme file throws an error because the req.headers.cookie is undefined, that cuses that the cookie.parse function throws an error since it is expecting a string not an undefined. I solved by just adding

if (process.server && req.headers.cookie)

that produces the same result as the solution in this request