Skip to content

Switch lang not working with custom routes. #2122

Answered by simkuns
mrFANRA asked this question in Q&A
Discussion options

You must be logged in to vote

The issue stems from the fact that @nuxtjs/i18n utilizes the extendPages hook to retrieve the list of registered routes only during the build phase. However, app/router.options.ts is served as is once the server is already up and running, hence the mismatch.

If you really want to have app/router.options.ts then you will have to add routes manually.

export default {
  routes: () => [
    {
      path: '/',
      name: 'index___ru',
      component: () => import('~/sections/index.vue'),
    },
    {
      path: '/en',
      name: 'index___en',
      component: () => import('~/sections/index.vue'),
    },
  ],
};

Here's an example on how you can use the pages:extend hook within your configur…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@mrFANRA
Comment options

@simkuns
Comment options

Answer selected by mrFANRA
@mrFANRA
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants