Fix dynamic default locale routing

This commit is contained in:
MOH
2026-03-15 04:41:08 +01:00
parent 50c3f5cce9
commit 364f761420
13 changed files with 73 additions and 32 deletions
+7 -3
View File
@@ -196,9 +196,13 @@ export default async function middleware(request: NextRequest) {
configuredDefaultLocale !== routing.defaultLocale &&
!hasLocalePrefix(pathname)
) {
const redirectUrl = request.nextUrl.clone();
redirectUrl.pathname = getLocalizedPathWithDefault(configuredDefaultLocale, pathname, routing.defaultLocale);
return NextResponse.redirect(redirectUrl, 307);
const rewriteUrl = request.nextUrl.clone();
rewriteUrl.pathname = getLocalizedPathWithDefault(
configuredDefaultLocale,
pathname,
routing.defaultLocale,
);
return NextResponse.rewrite(rewriteUrl);
}
if (