import { NextResponse, type NextRequest } from "next/server"; /** * Preview (WEBSITE-1.0-PLAN ยง4): a signed-in admin sees the working copy on the site's own * addresses, fully clickable. The cookie only asks for it; the backend checks the admin's session * on every page (site/preview), so it shows nothing to anyone else. */ export function GET(request: NextRequest) { const res = NextResponse.redirect(new URL("/", request.url), 303); const opts = { httpOnly: true, sameSite: "lax" as const, secure: process.env.NODE_ENV === "production", path: "/" }; res.cookies.set("ccw_preview", "admin", opts); // "Choose your template": the church's own content in another template, nothing saved. const template = request.nextUrl.searchParams.get("template"); if (template && /^(heritage|bold|community|clean)$/.test(template)) res.cookies.set("ccw_preview_template", template, opts); else res.cookies.delete("ccw_preview_template"); return res; }