From d00093a85a724510b6e2eae6be8a68d9afe594b6 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Fri, 4 Aug 2023 10:00:59 +0200 Subject: [PATCH] Move the navigation guard at Router level to prevent late redirects --- resources/js/routes.js | 4 ++++ resources/js/views/Error.vue | 8 -------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/resources/js/routes.js b/resources/js/routes.js index 855d75d6..23e6ef99 100644 --- a/resources/js/routes.js +++ b/resources/js/routes.js @@ -85,6 +85,10 @@ router.beforeEach((to, from, next) => { } else next() } + else if (to.name === 'genericError' && to.params.err == undefined) { + // return to home if no err object is provided to prevent an empty error message + next({ name: 'accounts' }); + } else next() }); diff --git a/resources/js/views/Error.vue b/resources/js/views/Error.vue index 5ee262e9..eb01a43f 100644 --- a/resources/js/views/Error.vue +++ b/resources/js/views/Error.vue @@ -88,14 +88,6 @@ }); }, - - beforeRouteEnter (to, from, next) { - // return to home if no err is provided to prevent an empty error message - if (to.params.err == undefined) { - next({ name: 'accounts' }); - } - else next() - }, }