nuxt icon indicating copy to clipboard operation
nuxt copied to clipboard

Reload on 404 option

Open Hulkmaster opened this issue 4 years ago • 2 comments

What problem does this feature solve?

Currently we have our old application, which just responds with new html each request, and now we want to start gradual migration to nuxt

its too expensive to migrate in one go, so some routes are old and some are new

But if nuxt doesn't know the route, it just displays regular 404 page, but that route might actually be handled by old app.

So it would be nice to have something like 404-strategy option, where it would be possible to define how nuxt should handle 404 pages So in our case if nuxt had not found 404 page it should just reload page

So currently we have page mixin which does

  beforeRouteLeave(to, from, next) {
    if (to.meta && to.meta.routeDummy) {
      // If route is dummy - reload the page to go to fallback blade route.
      // Dummy routes are defined in nuxt.config.js file
      // Need to do it in leave hook. In before-enter we can see error page
      window.location.href = to.fullPath;
      next(false);
    } else {
      next();
    }
  }

What does the proposed changes look like?

export default {
  router: {
    '404-strategy': () => {}, // or predefined strings like 'reload'
  }
}

Hulkmaster avatar Apr 20 '20 13:04 Hulkmaster