Static GitHub Issues

[205] `this.$router.replace` not works well

prev: plugin.apply is not a function
next: Static brotli files on production build
<button @click="logout">Logout</button>
export default {
  fetch ({store, redirect}) {
    if (!store.state.authUser) {
      return redirect('/login')
    }
  },
  methods: {
    logout () {
      this.$store.dispatch('logout');
//      this.$nuxt.$router.replace({ path: 'login' });
//      this.$nuxt.$router.replace({ path: 'test' });
      window.location.href = 'login';
    }
  }
}

In this case, when i use this.$nuxt.$router.replace({ path: 'test' }), i am redirected to localhost:3000/test and it requested localhost:3000/api/users/test at the sametime. But when i use this.$nuxt.$router.replace({ path: 'login' }), it didn't redirect. And in vue-dev-tools, i can see it didn't emit an routeChanged event. As a workaround, i use window.location.href = 'login' temporarily. I don't know if $router in a method page is the right way to browser redirects.

Thanks in advance for awesome nuxt.

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c174">#c174</a>)</em></sub></div>