From c60d2e11286986a4ea9abd6e464857f22e7ad6ff Mon Sep 17 00:00:00 2001 From: Yoshie Muranaka Date: Mon, 1 Jun 2020 09:44:23 -0700 Subject: Fix duplicate navigation error Adding a check to the 403 response api iterceptor before routing to the Unauthorized page. The router throws a NavigationDuplicated error when attempting to navigate to the same page. Signed-off-by: Yoshie Muranaka Change-Id: Ib34d4d73a326440f609dd97d0dd677ff96b7b3a6 --- src/store/api.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/store') diff --git a/src/store/api.js b/src/store/api.js index c8f1edae..4a8b8e80 100644 --- a/src/store/api.js +++ b/src/store/api.js @@ -19,6 +19,13 @@ api.interceptors.response.use(undefined, error => { } if (response.status == 403) { + if (router.history.current.name === 'unauthorized') { + // Check if current router location is unauthorized + // to avoid NavigationDuplicated errors. + // The router throws an error if trying to push to the + // same/current router location. + return; + } router.push({ name: 'unauthorized' }); } -- cgit v1.2.3