Repository nuxt.js

Middleware store dispatch or commit before redirect will not write data on server

Wei12345
5
Wei12345
commented 7 months ago

Sorry, my English is poor
glitch

When you visit index.vue on server
It has a middleware test.js

store.commit('SET_USER', 'hello');
return redirect('/about');

You will be redirect to about.vue
You will find that authUser is null

You click the back link to repeat the above action on client
You will find that authUser has value

0
rhwilr
35
rhwilr
commented 5 months ago

Can verify. I just stumbled upon this issue as well.

0
kirillbunin
0
kirillbunin
commented 4 months ago

Same here, nuxt 1.4.0

0
aldarund
102
aldarund
commented 3 months ago

Because redirect on server do a server side redirect so its like a full page reload…

0
shhdgit
0
shhdgit
commented 3 months ago

@aldarund But how can I pass the store when redirect.

0
aldarund
102
aldarund
commented 3 months ago

@shhdgit afaik you cant. Only solutions is to use persisted vuex state or pass params that u need via url params.

0
shhdgit
0
shhdgit
commented 3 months ago

@aldarund Thanks.

0
galvez
845
galvez
commented a month ago

@shhdgit you can use Set-Cookie too.

0
Informations
QuestionUnresolved
#c2568 - Created 7 months ago