How to add new route dynamically in Nuxt2?

56 Views Asked by At

I have routes, which depend on domain of the site.

Previously I used extendRoutes. Now, I can't use it, because I use the one copy for different domains.

I have tried use router.addRoute in nuxtServerInit and in the middleware, but didn't work.

    const routes = app.router.getRoutes();
    const { components } = routes.find(route => route.path === '/about')

    app.router.addRoute({
      path: '/about-test',
      name: 'about111',
      component: components['default']
    });
0

There are 0 best solutions below