I'm facing the 404 issue when trying to access any page of my Next.js application.
App works fine when no localeSubpaths
config is provided.
After implementing localeSubpaths
config (next.config.js):
const localeSubpaths = {
en: "en",
"de-DE": "de-DE",
fr: "fr"
};
app is not working any more.
Every time I'm trying to access main root /
or any of the locale pages fr
, de-DE
browser displays the 404 Error Page (Customized Next.js error page). This page contains some translated content which works fine.
Page contains also a link to the /
Home Page. When I'm navigation to the Home Page by clicking on the link -> Home Page loads correctly (including related translations)
i18n.tsx
config file:
import NextI18Next from "next-i18next";
import getConfig from "next/config";
import path from "path";
const { publicRuntimeConfig } = getConfig();
const { localeSubpaths } = publicRuntimeConfig;
const NextI18NextInstance = new NextI18Next({
defaultLanguage: "en",
ns: ["common"],
defaultNS: "common",
otherLanguages: ["de-DE", "de-CH", "fr"],
strictMode: false,
localeSubpaths,
localePath: path.resolve("./public/static/locales")
});
export default NextI18NextInstance;
const {
appWithTranslation,
i18n,
Link,
withTranslation,
Router
} = NextI18NextInstance;
export { appWithTranslation, i18n, Link, withTranslation, Router };