Closed jornwildenbeest closed 3 years ago
In my store, I have tickets, which are not fetched from the backend (since it's WIP). They are loaded from a file. No problems.
ATM if I fetch products or the user from the backend the cookie does not get updated. Even the tickets are not saved anymore...
Im using Nuxt 2.15.XX with SSR enabled and "vuex-persistedstate": "^4.0.0-beta.3" "js-cookie": "^2.2.1",
This does not look like a bug with the plugin but with your application. Please ask for help on either StackOverflow or any Nuxt / Vue related forums.
vuex-persistedstate
version: 4.0.0-beta.3node
version: v12.18.3npm
(oryarn
) version: 1.22.10What you did:
I was working on a Nuxt website with JWT Authentication, so I created a middleware in Nuxt to check if the jwtExpiresAt time was in the past, to know when to refresh the JWT token.
What happened:
While I was working on the middleware I tried to update the new refreshed JWT token in the store with a store action. I discoverd that when you use
await store.dispatch('auth/login')
the session is not being updated.. Turn's out is does update over client side, but when the middleware is called over SSR, say the first page load after hitting command + r or ctrl f5 is does not.My middleware auth.js:
Don't forget to add the middleware in nuxt.config.js --> router:
my store auth.js:
middleware logs from console:
Actual session:
Reproduction sandbox:
I created a brand new testing repo to double check if I wasn't causing the issues by some of my code: https://github.com/jornwildenbeest/nuxt-vuex-persistedstate-test
Problem description:
Javascript session is not being updated when calling store action from nuxt middleware over SSR. Turn's out is does update over client side, but when the middleware is called over SSR, say the first page load after hitting command + r or ctrl f5 is does not.