CSP & HTTP Security Headers Generator
Build an A+ Content-Security-Policy, HSTS, and Permissions-Policy header configuration with 1-click third-party presets and instant exports for Next.js, Vercel, Nginx, Cloudflare, and Apache.
CSP & HTTP Security Headers Generator: the tool
1-Click Third-Party Service Allowlists
Content-Security-Policy Directives
HTTP Hardening Headers (HSTS, Permissions, COOP)
Platform Config Export
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
async headers() {
return [
{
source: "/(.*)",
headers: [
{ key: "Content-Security-Policy", value: "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https:; connect-src 'self'; font-src 'self' data:; frame-src 'none'; frame-ancestors 'none'; object-src 'none'; base-uri 'self'; upgrade-insecure-requests" },
{ key: "Strict-Transport-Security", value: "max-age=63072000; includeSubDomains; preload" },
{ key: "X-Frame-Options", value: "DENY" },
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
{ key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=(), browsing-topics=()" },
{ key: "Cross-Origin-Opener-Policy", value: "same-origin" },
],
},
];
},
};
export default nextConfig;Hardening a Next.js, SaaS, or fintech application for SOC 2 or enterprise security reviews?
DEESU implements nonce-based CSP middleware, edge WAF rules, and end-to-end web application security audits.
How it works
Why Content-Security-Policy (CSP) Is Your Strongest Defense Against XSS
Cross-Site Scripting (XSS) remains one of the highest-impact vulnerabilities in modern web applications. Even when frameworks like React, Vue, or Next.js escape HTML by default, a single unsafe dangerouslySetInnerHTML, compromised npm package, or third-party marketing tag can inject malicious JavaScript capable of exfiltrating session tokens, hijacking checkout forms, or skimming credit cards.
A strict Content-Security-Policy HTTP response header shifts security enforcement directly into the user's browser. By declaring an explicit allowlist for script-src, connect-src, frame-src, and object-src, the browser immediately refuses to execute injected inline scripts or beacon stolen data to unauthorized domains—turning a catastrophic account takeover into a blocked console violation.
Essential HTTP Security Headers Beyond CSP
A complete defense-in-depth header baseline pairs CSP with five lightweight response headers that neutralize entire classes of browser attacks with almost zero latency overhead:
- Strict-Transport-Security (HSTS): Forces browsers to connect strictly over HTTPS for two years (
max-age=63072000; includeSubDomains; preload), defeating SSL stripping on public Wi-Fi. - X-Frame-Options & CSP frame-ancestors: Prevents malicious sites from wrapping your dashboard or checkout page in a hidden iframe to trick users into unintended clicks (clickjacking).
- X-Content-Type-Options: nosniff: Stops browsers from guessing MIME types on uploaded files (preventing an attacker from disguising JavaScript inside an image upload).
- Referrer-Policy: Setting
strict-origin-when-cross-originprevents sensitive URL paths and query tokens from leaking to third-party sites in the HTTPRefererheader. - Permissions-Policy & COOP: Explicitly revokes unused browser APIs like
camera=(),microphone=(), andgeolocation=(), whileCross-Origin-Opener-Policy: same-originisolates your browsing context from cross-origin popups (Spectre mitigation).
Rolling Out CSP Safely Without Breaking Production Analytics or Checkout
The #1 reason teams abandon Content-Security-Policy is deploying a strict policy directly in enforcement mode and accidentally blocking Google Tag Manager, Stripe Elements, Google Fonts, or YouTube embeds. Always start by enabling Content-Security-Policy-Report-Only in staging or for your first week in production. In Report-Only mode, the browser logs every violation in DevTools without breaking live functionality.
Once your audit shows zero unexpected violations, switch back to the enforcing Content-Security-Policy header. Whenever you integrate a new SaaS widget or payment SDK, add only the exact hostnames required (such as https://js.stripe.com in script-src and frame-src) rather than falling back to wide * wildcards.
Deploying Security Headers Across Next.js, Vercel, Cloudflare, Nginx, and Apache
Unlike HTML <meta http-equiv> tags—which ignore frame-ancestors, X-Frame-Options, and Report-Only—true HTTP response headers must be emitted by your web server, CDN edge, or framework middleware. Static hosts like Cloudflare Pages and Netlify read a plain-text public/_headers file at deploy time; Vercel reads vercel.json; Next.js supports async headers() in next.config.ts (or dynamic per-request nonces in middleware.ts); and self-hosted Linux servers apply add_header ... always; in Nginx or Header always set in Apache.
Questions, answered
'unsafe-inline' in script-src permits any <script> tag or onclick= handler injected into your HTML to execute—defeating CSP's primary protection against Cross-Site Scripting (XSS). For production apps requiring inline scripts, generate a cryptographic per-request nonce in middleware (e.g. Next.js middleware.ts) or use SHA-256 script hashes.frame-ancestors over X-Frame-Options, so frame-ancestors 'none' is the canonical standard. However, keeping X-Frame-Options: DENY alongside it provides backwards compatibility with legacy clients and satisfies automated compliance scanners (like Mozilla Observatory and SecurityHeaders.com).includeSubDomains; preload once you are 100% certain that your root domain AND every single subdomain (including staging, mail, or internal portals) will serve valid HTTPS certificates permanently. Removing a domain from the Chrome HSTS Preload list takes months.Cross-Origin-Opener-Policy: same-origin severs window.opener communication with cross-origin popup windows. If your app uses Google Sign-In popups, OAuth popups, or certain third-party payment popups, switch COOP to same-origin-allow-popups._headers file inside your public/ directory (e.g. public/_headers). Vite automatically copies it to dist/_headers during npm run build, where Cloudflare Pages and Netlify automatically apply it to every HTTP response.Related reading and help
Web DevelopmentContent Security Policy (CSP) & HTTP Security Headers in 2026: Stop XSS Without Breaking Next.js or Analytics
Master strict Content Security Policy (CSP), nonces, HSTS, and Permissions-Policy in 2026. Stop XSS attacks without breaking Next.js, Stripe, or Google Ads.
Nov 18, 202610 min read
Web DevelopmentNext.js 16 & React 19 Server Actions Security: Defending Against State Leaks, IDOR & CSRF
Why 'use server' functions are public API endpoints. Learn how to secure Next.js 16 Server Actions against IDOR, closure leaks, and unvalidated payloads.
Nov 3, 20266 min read
Cloud & DevOpsSoftware Supply Chain Security in 2026: CycloneDX SBOMs, Malicious NPM Defense & Lockfile Integrity
Protect applications against software supply chain attacks in 2026. Master CycloneDX SBOM generation, malicious npm package defense, and lockfile verification.
Nov 6, 20266 min read- DEESU serviceWeb DevelopmentWeb applications built to be found and built to convert — SEO-minded from the first commit, from storefronts to internal portals.See the service
More free tools
- Open Graph & social meta tag generatorGenerate and test Open Graph, Twitter Card, and SEO meta tags with live previews for Google, X, LinkedIn, and Facebook.
- Google Play & App Store fee calculatorCalculate your exact take-home payout, compare standard 15% vs 30% cuts, and test if external billing saves money.
- App cost calculatorEstimate a price range for an Android app or website from its features, in your local currency.
- Google Play launch checklistAn interactive checklist covering the store listing, policies, quality checks and release steps.
- Project brief generatorAnswer a few questions and get a clear, copyable brief you can send to any development team.
- App privacy policy generatorAnswer a few questions and get a plain-English privacy policy and a delete-account page for your Android or iOS app.
- App icon generatorUpload one image and download every Android, iOS and favicon size, with adaptive icon safe-zone checks.
- Play Store listing optimizerCheck your title, short and full description against keyword, readability and Google Play policy rules.
- LLM token & cost calculatorForecast production AI API expenses across OpenAI, Anthropic & DeepSeek. Model prompt caching savings and routing arbitrage.
- JWT debugger & security inspectorDecode, verify, and audit JSON Web Tokens for alg:none bypasses, key confusion attacks, expiry status and leaked secrets.
- Cron expression generator & explainerBuild, validate and translate crontab schedules for Linux, AWS EventBridge, GitHub Actions and Kubernetes.
- JSON to TypeScript & Zod converterInstantly convert raw API JSON payloads into clean TypeScript interfaces and production Zod v3 validation schemas.
- Docker Run to Docker Compose converterConvert raw docker run commands into production Docker Compose v2 YAML with automated security hardening and healthchecks.
- cURL to Code converter (Fetch, Axios, Python, Go)Translate cURL commands into JavaScript fetch, Axios, Python requests, Go, Rust, and Node.js with 100% in-browser privacy.
- SVG optimizer & React JSX converterMinify and clean vector SVGs, strip Figma metadata, and convert to production React JSX, React Native, or Vue components.
- Regex tester, debugger & ReDoS auditorTest regular expressions live with capture groups, replace previews, plain-English explanations, and catastrophic backtracking detection.
- JSON formatter, validator & diff viewerBeautify, validate, minify, sort keys, and compare two JSON payloads side by side with nested JSONPath diff inspection.
- SQL formatter & query linterBeautify PostgreSQL, MySQL, SQLite, and T-SQL queries and catch SELECT *, missing WHERE clauses, and slow non-sargable scans.
- CSS to Tailwind v4 converter & OKLCH paletteConvert raw CSS declarations to Tailwind v4 utility classes and generate accessible 50–950 OKLCH color scales with @theme export.
- Base64, URL, HTML & SHA-256 hash toolkitEncode/decode Base64 (UTF-8 & URL-safe), URLs, HTML entities, Hex, and generate SHA-256, SHA-512 & HMAC signatures offline.
- UUID v7, UUID v4, ULID & NanoID generatorBulk generate cryptographically secure RFC 9562 UUID v7, UUID v4, ULID, and custom NanoIDs and decode embedded timestamps.
- Linux chmod permissions calculatorCalculate Linux octal and symbolic file permissions (755, 644, 600), configure SetUID/SetGID/Sticky bits, and export chmod commands.
- Robots.txt generator & AI bot blockerBuild valid robots.txt rules, control GPTBot, ClaudeBot, and CCBot AI crawlers, declare sitemaps, and test URL paths live.
- Markdown table & GitHub README builderCreate formatted Markdown tables visually, import CSV/TSV spreadsheets, and build GitHub alert callouts and Shields.io badges.
Tell us what you're building.
Send the problem, not a polished brief. We'll tell you what it actually takes to ship it: stack, timeline and cost, before you commit to anything.