spb/datacenterindex
Public
HTML 53.9%
TypeScript 44.5%
JavaScript 0.6%
SQL 0.5%
1import { cookies, headers } from "next/headers";2import { redirect } from "next/navigation";3import type { ReactNode } from "react";4import { AdminShell } from "@/components/admin/shell";5import { ADMIN_COOKIE } from "@/lib/admin-api";67export const dynamic = "force-dynamic";89/**10 * Auth guard for every console page: no `dci_admin` cookie → /admin/login?next=…11 * The token itself is validated by the API on each proxied call (a stale cookie yields 401 → the client hook12 * redirects to the login page with reason=expired).13 */14export default async function AdminShellLayout({ children }: { children: ReactNode }) {15 const jar = await cookies();16 if (!jar.get(ADMIN_COOKIE)?.value) {17 const h = await headers();18 const next = h.get("x-invoke-path") ?? h.get("next-url") ?? "/admin";19 redirect(`/admin/login?next=${encodeURIComponent(next.startsWith("/admin") ? next : "/admin")}`);20 }21 return <AdminShell>{children}</AdminShell>;22}23