Framework Security
Hardening Next.js App Router, Server Actions, CSP, and Headers
Protect Server Actions, Route Handlers, JSON-LD scripts, and HTTP headers in production Next.js deployments on Vercel.
Prerequisites
- Next.js 14/15 App Router project
STEP 01
Verify session and ownership inside every Server Action
Do not rely strictly on middleware; re-authenticate and scope DB writes inside every exported action.
STEP 02
Configure CSP, HSTS, COOP, and CORP
Block framing with frame-ancestors 'none' and escape '<', '>', and '&' before injecting JSON-LD.
Related AegisSec skills