Next.js locale files are getting 404 because of setting basePath?

1.1k views Asked by At

Locale files are getting 404 , because of adding basePath ,

What i have tried i18n.tsx

  const NextI18NextInstance = new NextI18Next({
  defaultLanguage: 'en',
  otherLanguages: ['de'],
  fallbackLng: 'en',
  localeSubpaths,
  localePath: path.resolve('./public/static/locales'),
})

Updated above code with basePath like below ,

  const NextI18NextInstance = new NextI18Next({
  defaultLanguage: 'en',
  otherLanguages: ['de'],
  fallbackLng: 'en',
  localeSubpaths,
  localePath: path.resolve('./<basepath>/public/static/locales'),
})

But this is throwing internal server error.

1

There are 1 answers

0
Gopinath Kaliappan On

Hi folks fixed it by this configuration in i18n.tsx Need to add backend in i18n.tsx

  const NextI18NextInstance = new NextI18Next({
     backend: {
      loadPath: `https://${apiDomainName}/<basepath>/static/locales/{{lng}}/{{ns}}.json`,
     },
  })

apiDomainName can be localhost:3000 or www.your-webiste.com