Fix maintenance mode gating for visitors and superadmin session
CI / quality (push) Waiting to run

This commit is contained in:
MOH
2026-03-06 15:43:31 +01:00
parent 59bc4a6563
commit 4226c8bf51
4 changed files with 139 additions and 3 deletions
+9 -1
View File
@@ -1,8 +1,10 @@
import type { ReactNode } from "react";
import { unstable_noStore as noStore } from "next/cache";
import { redirect } from "next/navigation";
import { Footer } from "@/components/footer";
import { Navbar } from "@/components/navbar";
import { isAdminAuthenticated } from "@/lib/admin-auth";
import { getMaintenanceMode } from "@/lib/app-config";
import { resolveLocale } from "@/lib/site-data";
@@ -13,11 +15,17 @@ type SiteLayoutProps = {
};
};
export const dynamic = "force-dynamic";
export const revalidate = 0;
export default async function SiteLayout({ children, params: { locale } }: SiteLayoutProps) {
noStore();
const localeKey = resolveLocale(locale);
const maintenanceEnabled = await getMaintenanceMode();
const authenticated = isAdminAuthenticated();
if (maintenanceEnabled) {
if (maintenanceEnabled && !authenticated) {
redirect(`/${localeKey}/coming-soon`);
}
+6
View File
@@ -1,4 +1,5 @@
import type { ReactNode } from "react";
import { unstable_noStore as noStore } from "next/cache";
import { NextIntlClientProvider } from "next-intl";
import { getMessages, setRequestLocale } from "next-intl/server";
import { notFound } from "next/navigation";
@@ -13,6 +14,9 @@ type LocaleLayoutProps = {
};
};
export const dynamic = "force-dynamic";
export const revalidate = 0;
export function generateStaticParams() {
return routing.locales.map((locale) => ({ locale }));
}
@@ -21,6 +25,8 @@ export default async function LocaleLayout({
children,
params: { locale },
}: LocaleLayoutProps) {
noStore();
if (!routing.locales.includes(locale as (typeof routing.locales)[number])) {
notFound();
}