user3009752
user3009752

Reputation: 184

NextJS cannot disable redirect on domain

I have the following next-i18next.config.js file

 module.exports = {
  i18n: {
    locales: ["en", "de-DE", "fr"],
    defaultLocale: "en",
    localeDetection: false,
    domains: [
      {
        domain: "my-domain.com",
        defaultLocale: "en",
      },
      {
        domain: "my-domain.fr",
        defaultLocale: "fr",
        http: true,
      },
      {
        domain: "my-domain.de",
        defaultLocale: "de-DE",
        http: true,
      },
    ],
  },
};

I have set localeDetection to false, but when I change the language from en to fr my app is being redirected to http://my-domain.fr

My next.config.js is the following

const { i18n } = require("./next-i18next.config");

module.exports = {
  i18n,
};

Am I missing something?

Upvotes: 1

Views: 1644

Answers (1)

Mario Nikolaus
Mario Nikolaus

Reputation: 2406

I think you don't have right understanding of what locale detection exactly do.

Locale detection will automatically redirect user to correct locale website/page depending on his language preferences. What seems to bother you is that your locale is set to specific domain so your next router will always redirect you to the domain you have associated with your locale. So that is expected behaviour.

With locale detection set to false, you simply don't redirect user initially to his preferred locale.

Upvotes: 1

Related Questions