diff --git a/packages/now-next/src/index.ts b/packages/now-next/src/index.ts index 5a5efff8f47..47b20301ed9 100644 --- a/packages/now-next/src/index.ts +++ b/packages/now-next/src/index.ts @@ -2023,13 +2023,26 @@ export const build = async ({ { // TODO: enable redirecting between domains, will require // updating the src with the desired locales to redirect - src: '/', + src: `^${path.join( + '/', + entryDirectory + )}/?(?:${i18n.locales + .map(locale => escapeStringRegexp(locale)) + .join('|')})?/?$`, locale: { redirect: i18n.domains.reduce( (prev: Record, item) => { prev[item.defaultLocale] = `http${ item.http ? '' : 's' }://${item.domain}/`; + + if (item.locales) { + item.locales.map(locale => { + prev[locale] = `http${item.http ? '' : 's'}://${ + item.domain + }/${locale}`; + }); + } return prev; }, {} diff --git a/packages/now-next/src/utils.ts b/packages/now-next/src/utils.ts index 2ccb2fb8ded..d47aa796dfd 100644 --- a/packages/now-next/src/utils.ts +++ b/packages/now-next/src/utils.ts @@ -332,6 +332,7 @@ export type RoutesManifest = { domains?: Array<{ http?: boolean; domain: string; + locales?: string[]; defaultLocale: string; }>; };