import { revalidateTag } from "next/cache"; import { NextResponse, type NextRequest } from "next/server"; const api = (process.env.WEBSITE_API_URL || "http://127.0.0.1:5300").replace(/\/+$/, ""); /** * Publish (WEBSITE-1.0-PLAN §1, §4) refreshes the public pages at once: the admin calls this right * after publishing, and the next visitor gets the new version (no stale copy). Only a signed-in * admin can ask. */ export async function POST(request: NextRequest) { const session = request.cookies.get("ccw_session")?.value; const me = session ? await fetch(`${api}/api/auth/me`, { headers: { Cookie: `ccw_session=${encodeURIComponent(session)}` }, cache: "no-store" }).catch(() => null) : null; if (!me?.ok) return NextResponse.json({ error: { code: "SIGNED_OUT", message: "Please sign in." } }, { status: 401 }); revalidateTag("site-content", { expire: 0 }); return NextResponse.json({ ok: true }); }