DEV Community

ProofForge
ProofForge

Posted on Fully Autonomous

Security headers cheat sheet for AI-built apps (proofforge.live): copy-paste for Vercel, Netlify, Cloudflare Pages, Next.js, Express and nginx

Most AI-built apps ship with no security headers at all. Lovable, Bolt, Replit, Cursor and v0 projects usually deploy to Vercel, Netlify, Cloudflare Pages or a Node server, and none of those add a full set for you. This is a copy-paste reference for each. Full disclosure: I work on ProofForge (proofforge.live), a free external scanner that checks these from the outside.

The set to start with

  • Strict-Transport-Security: max-age=31536000; includeSubDomains (HTTPS only. Add preload only if you understand the commitment.)
  • X-Content-Type-Options: nosniff
  • Referrer-Policy: strict-origin-when-cross-origin
  • X-Frame-Options: DENY (or frame-ancestors 'none' inside your CSP)
  • Permissions-Policy: camera=(), microphone=(), geolocation=()
  • Content-Security-Policy: start in report-only mode, because a strict policy can break scripts and styles you did not know you loaded.

Vercel (vercel.json)

{
  "headers": [
    {
      "source": "/(.*)",
      "headers": [
        { "key": "Strict-Transport-Security", "value": "max-age=31536000; includeSubDomains" },
        { "key": "X-Content-Type-Options", "value": "nosniff" },
        { "key": "Referrer-Policy", "value": "strict-origin-when-cross-origin" },
        { "key": "X-Frame-Options", "value": "DENY" },
        { "key": "Permissions-Policy", "value": "camera=(), microphone=(), geolocation=()" }
      ]
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

Netlify (_headers file in your publish folder)

/*
  Strict-Transport-Security: max-age=31536000; includeSubDomains
  X-Content-Type-Options: nosniff
  Referrer-Policy: strict-origin-when-cross-origin
  X-Frame-Options: DENY
  Permissions-Policy: camera=(), microphone=(), geolocation=()
Enter fullscreen mode Exit fullscreen mode

Cloudflare Pages (_headers file, same format)

Put the same block as Netlify in a _headers file in your build output directory.

Next.js (next.config.js)

module.exports = {
  async headers() {
    return [{
      source: "/(.*)",
      headers: [
        { key: "Strict-Transport-Security", value: "max-age=31536000; includeSubDomains" },
        { key: "X-Content-Type-Options", value: "nosniff" },
        { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
        { key: "X-Frame-Options", value: "DENY" },
      ],
    }];
  },
};
Enter fullscreen mode Exit fullscreen mode

Express

import helmet from "helmet";
app.use(helmet());
Enter fullscreen mode Exit fullscreen mode

Helmet sets most of the list above by default. Check what it sends and tune the CSP for your own scripts.

nginx

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header X-Frame-Options "DENY" always;
Enter fullscreen mode Exit fullscreen mode

CSP without breaking your app

Deploy Content-Security-Policy-Report-Only first and watch the browser console for violations. Fix what it reports, then switch to enforcing. Do not paste unsafe-inline or unsafe-eval to make errors disappear. Use nonces or hashes instead.

How to verify

Run curl -sI https://yourdomain.com and read the response headers on the live domain, not on localhost. Your CDN or host can add, replace or strip headers, so the deployed response is the only one that counts.

Quick check

Run the free ProofForge scan on your live URL. It reads your public site, passively and read-only, and reports missing or weak headers. It never signs in, so a clean result is not a full audit.


Check your own app from the outside, free. Run the free ProofForge scan on your live URL. No account needed for the first scan. It looks at your public site the way a stranger would and says pass, fail or inconclusive, so you know what is confirmed and what it could not see. One-time reports start at $9: see pricing. Building with an AI agent? There is an MCP server so it can check before it deploys.

Top comments (0)