Next.js Discord

Discord Forum

[nextI18n] basePath with custom domains not working properly

Unanswered
Birman posted this in #help-forum
Open in Discord
BirmanOP
Hello, i have a project using nexti18next with custom domains.
For now I need to move the project to a another domain as subpath and I configuring on nginx.

The problem is when I add the basePath config, the configured domains not working properly for locales.

In my next.config.js I have the basePath: '/recursos' and I created some preview domains to use and are configured:
https://dd-staging-ar.vercel.app/recursos // for AR
https://dd-staging-mx.vercel.app/recursos // for MX
https://dd-staging-br.vercel.app/recursos // for BR


In my next-i18next.config.js I have theses domains configured:
  {
    domain: "dd-staging-br.vercel.app",
    defaultLocale: "br",
  },
  {
    domain: "dd-staging-ar.vercel.app",
    defaultLocale: "ar",
  },
  {
    domain: "dd-staging-mx.vercel.app",
    defaultLocale: "mx",
  }


The problem with this is that all domains load BR version as defaultLocale.

Someone knows how to make works basePath with i18n in nextJS to load right locale for each domain?


Packages versions:
  "next": "12.3.4",
  "next-i18next": "^8.9.0",

0 Replies