redirect dose't work & ssr dose't work #9525
Replies: 1 comment
-
What are your With With This to run this lighter snippet of code as a middleware and understand what is happening with various configurations export default ({ app, redirect }) => {
console.log('process and cookies', process.server && !!app.$cookies.get('token'))
console.log('server', process.server)
console.log('client', process.client)
console.log('static', process.static)
if (process.server) {
console.log('redirect will be called shortly')
redirect('/login')
}
} So, every behavior is working as expected IMO. PS: for people who are willing to try this, OP is using cookie-universal-nuxt when he uses The second part of your question is probably working as expected too, since your SPA is following what you've asked it to do (it moves thanks to |
Beta Was this translation helpful? Give feedback.
-
hello,
my first problem is redirect dose't work in middleware,
console.log('redirect') is ok,
but 'redirect('/login')' cant work, nuxt version is 2.15.7
auth.js:
userCenter.vue
my second problem is when i use nuxt-link or this.$router.push to jump to homepage, homepage ssr (i used asyncData) dont work。 instead, the requests in asyncData runed at frontend by ajax, like
how to fixed?thxs~!
Beta Was this translation helpful? Give feedback.
All reactions