Move admin area to root subdomain
CI / quality (push) Waiting to run

This commit is contained in:
MOH
2026-03-12 00:15:12 +01:00
parent e7dab6f0ef
commit 87a597c872
50 changed files with 256 additions and 140 deletions
+6 -5
View File
@@ -4,6 +4,7 @@ import { revalidatePath } from "next/cache";
import { redirect } from "next/navigation";
import { routing } from "@/i18n/routing";
import { toInternalAdminPath } from "@/lib/admin-routing";
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
import { getLocalizedPath } from "@/lib/locale";
import { setMaintenanceMode } from "@/lib/app-config";
@@ -11,7 +12,7 @@ import { setMaintenanceMode } from "@/lib/app-config";
function ensureAdmin() {
if (!isAdminAuthenticated()) {
clearAdminSessionCookie();
redirect("/root");
redirect("/");
}
}
@@ -19,7 +20,7 @@ export async function updateMaintenanceModeAction(formData: FormData) {
ensureAdmin();
const nextValue = formData.get("enabled") === "true";
const redirectPath = String(formData.get("redirectPath") ?? "/root");
const redirectPath = String(formData.get("redirectPath") ?? "/");
const redirectUrl = new URL(redirectPath, "http://localhost");
redirectUrl.searchParams.set(
"success",
@@ -29,9 +30,9 @@ export async function updateMaintenanceModeAction(formData: FormData) {
await setMaintenanceMode(nextValue);
revalidatePath("/", "layout");
revalidatePath("/coming-soon");
revalidatePath("/root");
revalidatePath("/root/maintenance");
revalidatePath(redirectPath);
revalidatePath(toInternalAdminPath("/"));
revalidatePath(toInternalAdminPath("/maintenance"));
revalidatePath(toInternalAdminPath(redirectUrl.pathname));
for (const appLocale of routing.locales) {
revalidatePath(getLocalizedPath(appLocale), "layout");