Admin API and screens: dashboard and setup checklist, template and style, pages and blocks, ministries, leadership, media library with the storage limit, publish and history. Pending changes with who and when, discard one, one Publish, restore any version (each version keeps the working copy's rows, never sent to visitors). Preview on the site's own addresses with a bar (widths, back, publish); shared preview links for 7 days or until revoked. Roles checked, same-origin changes only. Publish refreshes the public pages at once (WEBSITE_CONTENT_CACHE_SECONDS). E2E on a production build: the admin's flows and axe on every screen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
13 lines
599 B
TypeScript
13 lines
599 B
TypeScript
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);
|
|
res.cookies.set("ccw_preview", "admin", { httpOnly: true, sameSite: "lax", secure: process.env.NODE_ENV === "production", path: "/" });
|
|
return res;
|
|
}
|