Static GitHub Issues

[2856] asyncData not called after vue-router hook beforeRouteEnter is called

prev: How multiple request API in nuxtServerInit?
next: How to get NODE_ENV=test/dev in statically generated site?

In order to have a completely separate Nuxt page for search versus our homepage, we implemented a redirect if the query string parameter q is present. We use vue-router’s beforeRouteEnter hook to implement the redirect:

  beforeRouteEnter (to, from, next) {
    if (typeof to.query.q !== 'undefined') {
      next({ name: 'domain', query: to.query, replace: true })
      return
    }
    next()
  }

Everything works great, except, on the server, asyncData isn’t called by the domain route. It otherwise loads and renders correctly, sans asyncData.

<!--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/c2481">#c2481</a>)</em></sub></div>