diff --git a/packages/now-next/src/index.ts b/packages/now-next/src/index.ts index eceba1dfae1..6b7e73e91ff 100644 --- a/packages/now-next/src/index.ts +++ b/packages/now-next/src/index.ts @@ -1651,6 +1651,7 @@ export const build = async ({ // if there isn't a srcRoute then it's a non-dynamic SSG page and if (nonDynamicSsg || isFallback) { routeFileNoExt = addLocaleOrDefault( + // root index files are located without folder/index.html routeFileNoExt, routesManifest, locale diff --git a/packages/now-next/src/utils.ts b/packages/now-next/src/utils.ts index b68f37a3971..e19f86753ef 100644 --- a/packages/now-next/src/utils.ts +++ b/packages/now-next/src/utils.ts @@ -1110,7 +1110,9 @@ export function addLocaleOrDefault( if (!routesManifest?.i18n) return pathname; if (!locale) locale = routesManifest.i18n.defaultLocale; - return locale ? `/${locale}${pathname}` : pathname; + return locale + ? `/${locale}${pathname === '/index' ? '' : pathname}` + : pathname; } export { diff --git a/packages/now-next/test/fixtures/00-i18n-support/pages/index.js b/packages/now-next/test/fixtures/00-i18n-support/pages/index.js index 1467602e631..24f4489b20a 100644 --- a/packages/now-next/test/fixtures/00-i18n-support/pages/index.js +++ b/packages/now-next/test/fixtures/00-i18n-support/pages/index.js @@ -44,3 +44,12 @@ export default function Page(props) { ); } + +export const getStaticProps = ({ locale, locales }) => { + return { + props: { + locale, + locales, + }, + }; +};