I18n-module: Too many redirects error since version 6.13.0 (0.3.1 nuxt-comunity/redirect-module)

Created on 19 Aug 2020  路  4Comments  路  Source: nuxt-community/i18n-module

Version

nuxt-i18n: 6.13.10
nuxt: 2.14.3
nuxt-comunity/redirect-module: 0.3.1

Nuxt configuration

Mode:

  • [X] universal
  • [ ] spa

Redirect module config

redirect: [
    {
      from: "^(\\/[^\\?]*[^\\/])(\\?.*)?$",
      to: (from, req) => {
        return "$1/$2";
      }
    }
  ]

Nuxt-i18n configuration

i18n: {
    parsePages: false,
    lazy: true,
    locales: [
      {
        territory: "US",
        name: "English",
        code: "en",
        iso: "en",
        file: "en.json"
      },
      {
        territory: "ES",
        name: "Espa帽ol",
        code: "es",
        iso: "es",
        file: "es.json"
      }
    ],
    detectBrowserLanguage: false,
    vueI18n: {
      fallbackLocale: "en"
    },
    vuex: {
      syncLocale: true,
      syncMessages: true
    },
    defaultLocale: "en",
    langDir: "locales/",
    seo: false
}

Reproduction Link

Sandbox

Steps to reproduce

Go to path /foo (or any other page that not existing)

What is Expected?

404 erorr

What is actually happening?

I have a small question about nuxt-i18n and nuxt-redirect modules. I think that it's issue, but i am not sure. I have updated the sandbox for reproduce. If you will try to get access to path /foo (or any other page that not existing) with current version of nuxt-i18n package (6.13.10) it will Too many requests error. But with version of package 6.12.0 is it works fine. What's really happening: every non-existent standard language page now has an error Too many requests instead of 404, when we are using trailing slash at the end as default.

bug 馃悰 stale

All 4 comments

nuxt-i18n tries to be smarter itself about redirecting to the correct path.
Do you see any issues or wrong paths with redirect module disabled?

If you want to consistently have trailing slashes in your paths then you should consider setting Nuxt option router.trailingSlash: true and then letting Nuxt and nuxt-i18n handle redirection.

(Just that there are some know issues currently with trailingSlash but it might be good enough for you.)

Hi @rchl. Thanks for an explanation. It doesn't work with only router.trailingSlash, but works with router.trailingSlash and nuxtjs/redirect-module.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings