Serve security headers

Security headers reduce injection, clickjacking and downgrade risk. Send HSTS with a long max-age, a Content-Security-Policy in report-only mode first, X-Content-Type-Options nosniff, a Referrer-Policy and frame-ancestors. Verify with curl headers on the production host before you enforce the policy.

lowIn codeimpact effort

Why this matters

HSTS, CSP and a few small headers cost nothing and protect every page.

Get the full breakdown

The extended brief explains when this works, when it does not, and the trade-offs. Join the waitlist and it unlocks for every tip when sign-in opens; MCP access is the paid part.

Join the waitlist

Before you start

  • HTTPS on all hosts
  • Access to edge or server configuration

How to apply it

  1. Record current headers

    Run curl -sI on the homepage, a content page and a 404. Record which security headers are present and their values.

    Check: The audit lists header presence per response, including the 404 page.

  2. Deploy headers at the edge

    Add HSTS, nosniff, Referrer-Policy and a report-only CSP covering frame-ancestors and upgrade-insecure-requests. Apply them to all responses.

    Check: curl -sI shows strict-transport-security, x-content-type-options and content-security-policy-report-only.

  3. Enforce after the reports are clean General best practice

    Review CSP reports, fix legitimate violations, then switch from report-only to enforcing. Raise HSTS max-age once confirmed stable.

    Check: The enforced CSP blocks no functional script, and HSTS max-age is at least one year.

Get the prompt for your agent

A ready-to-paste prompt for your agent that implements this tip and verifies the result in your repo.

Join the waitlist

Source: seo-mcp playbook · curated entry · report an error

Framework notes

nextjs-app

Set headers in `next.config.ts` under `async headers()` for all routes, or in middleware for per-request nonces; apply to `/:path*`.

astro

Use `src/middleware.ts` or the host adapter config to add headers; static-only deploys usually need the host's header rules instead.

Official references

Let your agent apply this + 161 more tips.

Pre-order — $19