Finalize multilingual routing and translations
CI / quality (push) Waiting to run

This commit is contained in:
MOH
2026-03-07 14:10:30 +01:00
parent 1ad9ae9629
commit 7f4277d1d7
53 changed files with 2805 additions and 1382 deletions
+9 -1
View File
@@ -3,6 +3,7 @@ import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
import { routing } from "./i18n/routing";
import { getLocalizedPath } from "./lib/locale";
const intlMiddleware = createMiddleware(routing);
const ADMIN_SESSION_COOKIE = "moh_admin_session";
@@ -139,6 +140,13 @@ export default async function middleware(request: NextRequest) {
const isRootBaseRoute = pathname === "/root" || pathname.startsWith("/root/");
const isRootRoute = isRootBaseRoute;
if (pathname === "/de" || pathname.startsWith("/de/")) {
const redirectUrl = request.nextUrl.clone();
const nextPath = pathname.slice(3) || "/";
redirectUrl.pathname = nextPath;
return NextResponse.redirect(redirectUrl, 308);
}
if (isRootRoute && isRootBasicAuthConfigured() && !isRootBasicAuthValid(request)) {
return new NextResponse("Authentication required", {
status: 401,
@@ -164,7 +172,7 @@ export default async function middleware(request: NextRequest) {
if (!isAdminAuthenticated) {
const targetLocale = locale ?? routing.defaultLocale;
const redirectUrl = request.nextUrl.clone();
redirectUrl.pathname = `/${targetLocale}/coming-soon`;
redirectUrl.pathname = getLocalizedPath(targetLocale, "/coming-soon");
redirectUrl.search = "";
return NextResponse.redirect(redirectUrl);
}