I'm trying to wrap my head around this problem I'm having. Let me break it down for you.
- I have a Nuxt project, which utilizes a modular store.
- I have a global middleware that only runs server side (meaning when the page is refreshed).
- This middleware is used to check if there's a cookie with user data, if so I'm making a post request to Firebase to evaluate the refresh token and fetch the user meta information (such as display name, etc). (I also tried using NuxtServerInit, I get the exact same problem)
- All of this works perfectly. It runs just fine and by logging everything I know it is working and the state is changed.
In a loginUser() method, it sets the state of the application. (A token and display name value). When I login through the web app itself the cookie gets set properly and the state as well. The token is stored there and the display name as well.
However if I refresh my page it goes through the middleware and sets the state, but then on render it seems to be discarding all these changes I made to the store on server side and resets the store ready to be used on the client side.
Am I missing a nuxt configuration here? Do I have to setup a specific key to tell nuxt to preserve the server side rendered store?
Does anybody have any experience with this happening? If so please point me in the right direction.