Reputation: 11
I have the route /myPath in my Vue.js application. I want it to be accesible only througth a router-link. Else, if an user tries to access directly he will be redirected to "not found" page.
Is this possible with Vue.js router features/functionalities?
Upvotes: 0
Views: 42
Reputation: 603
You can check the route user is trying to navigate from using Navigation Guards. Something like this, for example:
router.beforeEach((to, from, next) => {
if (from === "route_with_the_router_link") {
next()
} else {
next(false)
}
})
Upvotes: 1