Sign-in steps (password, sign-up, email code, two-step sign-in and its setup with recovery codes, privacy notice, news question), forgot and reset password, the account page, admin (people, deletions, church profile, linked products, settings, notice, licence, audit) and setup. Strict CSP with a nonce per page; church colours from the profile. @crosscode/ui gets its first components (shell, card, fields, buttons). Plan: roles stay in each product (asked 2026-11-18). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import { NextResponse, type NextRequest } from "next/server";
|
|
|
|
/**
|
|
* A strict Content-Security-Policy with a fresh nonce per page (docs/ACCOUNTS-1.0-PLAN.md §10):
|
|
* no inline scripts or styles except Next's own and the church's colours, both carrying the nonce.
|
|
* Sign-in pages never load anything from another site.
|
|
*/
|
|
export function proxy(request: NextRequest) {
|
|
const nonce = Buffer.from(crypto.randomUUID()).toString("base64");
|
|
const dev = process.env.NODE_ENV === "development";
|
|
const csp = [
|
|
"default-src 'self'",
|
|
`script-src 'self' 'nonce-${nonce}' 'strict-dynamic'${dev ? " 'unsafe-eval'" : ""}`,
|
|
`style-src 'self' 'nonce-${nonce}'`,
|
|
"img-src 'self' https: data:",
|
|
"font-src 'self'",
|
|
"connect-src 'self'",
|
|
"object-src 'none'",
|
|
"base-uri 'self'",
|
|
"form-action 'self'",
|
|
"frame-ancestors 'none'",
|
|
].join("; ");
|
|
const headers = new Headers(request.headers);
|
|
headers.set("x-nonce", nonce);
|
|
headers.set("Content-Security-Policy", csp);
|
|
const res = NextResponse.next({ request: { headers } });
|
|
res.headers.set("Content-Security-Policy", csp);
|
|
return res;
|
|
}
|
|
|
|
export const config = {
|
|
matcher: [{ source: "/((?!api|_next/static|_next/image|favicon.ico).*)", missing: [{ type: "header", key: "next-router-prefetch" }] }],
|
|
};
|