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.

Duplicate route names with prefix_and_default strategy

See original GitHub issue

Version

v5.3.0

Reproduction link

https://codesandbox.io/s/ql7wx2mvk6

Steps to reproduce

  1. Configure nuxt-i18n module with these settings:
    [
      "nuxt-i18n",
      {
        locales: [
          { code: "pt", iso: "pt-PT", file: "pt.json" },
          { code: "us", iso: "en-US", file: "en.json" }
        ],
        langDir: "locales/",
        lazy: true,
        strategy: "prefix_and_default",
        defaultLocale: "us"
      }
    ]
  1. Load the root path.
  2. Look at the console (the server one, at the bottom of the codesandbox UI)

What is expected ?

No warnings about duplicated routes.

What is actually happening?

Getting console warnings:

[vue-router] Duplicate named routes definition: { name: "about___us", path: "/us/about" } 
[vue-router] Duplicate named routes definition: { name: "index___us", path: "/us" }

Additional comments?

Appears to be due to using strategy: "prefix_and_default", setting which creates routes with duplicate names for default locale.

<div align="right">This bug report is available on Nuxt community (#c153)</div>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:9
  • Comments:5

github_iconTop GitHub Comments

2reactions
ruzpuzcommented, Jan 28, 2019

I am experiencing this issue as well… any way around it?

1reaction
ghostcommented, Nov 25, 2018

Another alternative to the above solution is to use routes.push({ ...route, path }) instead of routes.push({ ...localizedRoute, path }). This will still create a new route for the default route (which you might want for e.g. SEO purposes) but its name will be set to the base name of the route. For example, a contact route is currently generated into e.g. contact___en, but with this change the default locales routes name would just be contact.

Note that localePath will still move you to e.g. /en/contact from /contact, I still need to find a solution to that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Laravel 5.1 - Duplicated prefix while using route groups
Route names are build using both prefix and as if they are defined. That's the reason why you're getting the same prefix. The...
Read more >
Prefix Advertisement with Duplicate AS Numbers Overview
When a BGP speaker receives a route that has the speaker's AS number in its AS path, the speaker declares that route to...
Read more >
Bug: Duplicate route name, even with different prefix · Issue ...
You need to prefix the route's name by using the as() method in the group. Route.group(() => { Route ...
Read more >
Cisco Nexus 9000 Series NX-OS Unicast Routing ...
If you create an ACL named "prefix-list," it cannot be associated with a route map that is created using the match ip address...
Read more >
Configure route tables - Amazon Virtual Private Cloud
You can then specify the prefix list as the destination in your route table entry. Every route table contains a local route for...
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