import { NextRequest, NextResponse } from 'next/server'; const PUBLIC_PATHS = ['/login', '/reset-password']; /** * Build the Content-Security-Policy for a single request. * * Production uses a strict, nonce-based policy with `strict-dynamic`: only scripts * carrying this request's nonce (and scripts they load) may execute, which neutralises * reflected/stored XSS regardless of any host allowlist. Next.js applies the nonce to * its own bootstrap/chunk scripts automatically because middleware forwards it on the * request `Content-Security-Policy` header (see below); our own inline scripts read it * from the `x-nonce` request header in the root layout. * * `strict-dynamic` also covers the jsQR script the boarding scanner injects at runtime * (a trusted script's dynamically-created