question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Router is not generating proper routes

See original GitHub issue

Version

nuxt: 2.12.2, nuxt-i18n: 6.11.1

Nuxt configuration

mode:

  • universal

Reproduction link

https://codesandbox.io/s/nuxt-nuxt-i18n-base-template-8iqxp

Code

/pages structure: image

_id.vue:

<template lang="pug">
  div
    p Page
</template>

Configuration:

i18n: {
    defaultLocale: 'pl',
    lazy: true,
    langDir: 'lang/',
    locales: [
      {
        code: 'en',
        name: 'English',
        file: 'en-US.js',
        flag: '🇬🇧'
      },
      {
        code: 'pl',
        name: 'Polski',
        file: 'pl-PL.js',
        flag: '🇵🇱'
      },
    ],
}

autogenerated .nuxt/router.js: image image

What is Expected?

To have dynamic route working.

What is actually happening?

/en/therapists/:id is working even though in router it’s not prefixed now it’s not working too. When I switch to default locale (pl) then page is not found unless I type therapists instead of terapeuci.

/therapists (index.vue) works perfectly in both langs.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
janswistcommented, Jun 2, 2020

The simplest mistakes are the easiest to make. Thanks a lot! That solved my problem - can’t believe I didn’t thought of it by myself. Pozdrawiam 😃

0reactions
rchlcommented, Jun 2, 2020

You do need to also set custom paths for the dynamic route. Can’t expect those to follow the therapists/index.vue magically as those are two separate routes.

So add this for _id.vue route:

  nuxtI18n: {
    paths: {
      en: "/therapists/:id",
      pl: "/terapeuci/:id"
    }
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

nuxt-modules/i18n - Router is not generating proper routes
To have dynamic route working. What is actually happening? /en/therapists/:id is working even though in router it's not prefixed now it's not ......
Read more >
Solved: Router not routing - Cisco Community
1.254 and create a routing for 10.24.1.0/24 via 192.168.1.253. Also I believe that some of the routers must NAT 10.24.1.0/24 behind itself.
Read more >
Why is my router not routing? - Super User
It seems obvious, but check that things are cabled up right. Is the cable modem connected to the WAN port of the router?...
Read more >
Express router is not routing to the correct path even though ...
The page that it should be routed to is localhost:5000/users/login but it is instead routing localhost:5000/login. I was referencing the Vidjot ...
Read more >
Router tutorial: tour of heroes - Angular
Later, this guide shows you how to create multiple routing modules and import those routing modules in the correct order. The application continues...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found