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

Wei12345
5
Wei12345
commented a year 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 10 months ago

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

0
kirillbunin
0
kirillbunin
commented 9 months ago

Same here, nuxt 1.4.0

0
aldarund
428
aldarund
commented 8 months ago

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

0
shhdgit
0
shhdgit
commented 8 months ago

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

0
aldarund
428
aldarund
commented 8 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 8 months ago

@aldarund Thanks.

0
galvez
3.8k
galvez
commented 6 months ago

@shhdgit you can use Set-Cookie too.

0
Informations
QuestionUnresolved
#c2568 - Created a year ago