Disallow navigating to non-existing routes

This commit is contained in:
Richard Lewis 2019-11-08 11:58:58 +00:00 committed by Pavel Djundik
parent d232ef1557
commit 5c0a7722a4

View File

@ -34,6 +34,12 @@ const router = new VueRouter({
}); });
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
// Disallow navigating to non-existing routes
if (!to.matched.length) {
next(false);
return;
}
// Handle closing image viewer with the browser back button // Handle closing image viewer with the browser back button
if (!router.app.$refs.app) { if (!router.app.$refs.app) {
next(); next();