[Vuejs]-Vue / Vue-bulma – nprogress: Progress bar loads forever on guard/redirect

0👍

Isn’t simple to answer without see code in action, but, you can try to invert call to this.nprogess.done() and next(...) like this:

router.beforeEach((to, from, next) => {
  if (to.meta.requiresAuth) {
    const authUser = JSON.parse(window.localStorage.getItem('authUser'))
    if (authUser && authUser.auth) {
      next()
    } else {
      this.nprogress.done(); // <- HERE
      next({name: 'login'})
    }
  }
  next()
}

since next() call move context to new component, and I’m not sure call to nprogress will be called on the right moment.

Leave a comment