0👍
add a new meta key requiresNotAuth
for login and register routes then change beforeEach
content like this
if (to.matched.some(record => record.meta.requiresAuth)) {
if (!store.getters.isAuthenticated) {
next({name: 'login'})
} else {
next()
}
}
else if (to.matched.some(record => record.meta.requiresNotAuth)) {
if (store.getters.isAuthenticated) {
next({name: 'home'})
}
else {
next()
}
}
else {
next() // make sure to always call next()!
}
- [Vuejs]-Laravel + Vue js Deploying on Shared hosting
- [Vuejs]-VueJS2: How to update objects in an array and pass back to parent?
Source:stackexchange.com