Skip to content

Unprefixed routes are always added in full static mode when strategy is "prefix"

Closed

Description

Version

@nuxtjs/i18n: 7.0.3
nuxt: 2.15.7

Nuxt configuration

  • Applies to a site deployed to a static server (site generated with nuxt generate)
  • Applies to a site deployed to a server with a Node backend

@nuxtjs/i18n configuration

i18n: {
    strategy: 'prefix',
}

Reproduction Link

https://codesandbox.io/s/nuxt-nuxtjs-i18n-base-template-forked-ron65?file=/pages/index.vue

Steps to reproduce

  1. Set target: static in nuxt.config.js
  2. Set strategy: prefix in i18n config

What is Expected?

There should only be routes prefixed with locale codes

What is actually happening?

There are routes with prefixed locale codes as well as routes with unprefixed locale codes.
As you can see, the reproduction link prints all routes and for each page there is the prefixed version, ie: /en/about /es/about but also the unprefixed version: /about

I'd say that with setting the strategy to "prefix" this is an unexpected behaviour, especially considering it only happens in full static mode.

The reason why this happen is this logic:
https://github.com/nuxt-community/i18n-module/blob/c710ad18d30dc80c9e71502fbf0e722e596952c7/src/core/hooks.js#L13-L16

When full static mode is active or when nuxt generate runs, the variable includeUprefixedFallback is set to true which forces the route generation to include the unprefixed version of each route.

My question is why is this logic present? I guess there must be a good reason if it's there 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions