Skip to content

Security headers and HTTPS, set once for every response

Set HSTS, CSP, framing, MIME and referrer headers on every response, with CSP rolled out without breaking the site.

  • Free, no sign-up
  • 45 to 90 minutes with an agent
  • By Devvrat Hans
  • Version 1.0, updated Oct 26, 2026

1Your site and stack

Optional. The prompt adapts as you type; leave a field blank and the agent works it out.

2Copy it into your agent

security-headers.md68 lines, about 983 tokens

Paste into any coding agent: Claude Code, Cursor, Codex, Copilot, Windsurf or Cline.

# Security headers and HTTPS, set once for every response

Security headers are the cheapest protection the production site can have: a few lines of config that stop clickjacking, MIME sniffing, protocol downgrades and many script injections. Set them once, in one place, for every response, and roll out the Content-Security-Policy in report-only mode first so nothing breaks on launch day.

Site: not given. Find the production URL in the project config, or ask me.

## Ground rules

1. Read before you write. Explore the parts of the codebase this job touches and tell me what is already in place.
2. Plan, then stop. Give me a numbered plan: what you will change, in which files, and why. Wait for my approval before editing anything.
3. Fix things at their source (the shared layout, the config, the generator), not with one-off patches page by page.
4. Keep the project's conventions: its framework APIs, file layout, naming and code style. Add no new dependency without asking.
5. Where something is already done well, say so and leave it alone.

## You will not

- Edit `.env` files, secrets or API keys, or print their values.
- Deploy, push, merge or publish anything.
- Delete data, or run migrations or scripts against a production database.
- Add tracking, third-party scripts or links to any site I did not ask for.
- Change copy, design or behaviour that this job does not need.
- Enable HSTS preload without my confirmation.
- Switch the CSP to enforcing mode on its own.

## Your stack

- Framework: Work out the framework, router and build output from the project files (package.json, lockfiles, framework config) before planning, and say which you found.
- Host: Work out where the site is hosted from the config files (vercel.json, netlify.toml, wrangler config, Dockerfile, fly.toml) and say which you found.

## Steps

### 1. See what is sent today

Find where response headers are set (framework config, middleware, the current host config, a CDN rule in the repository) and list the headers the homepage, an API route and a static asset send now. Note anything set in two places that could disagree.

### 2. HTTPS everywhere

Every HTTP request should redirect to HTTPS in one hop. Add `Strict-Transport-Security: max-age=31536000; includeSubDomains`. Only add `preload` if I confirm every subdomain serves HTTPS, because preloading is hard to undo.

### 3. The simple headers

Set on every HTML response, from one place:

- `X-Content-Type-Options: nosniff`
- `Referrer-Policy: strict-origin-when-cross-origin`
- `X-Frame-Options: DENY` (or `SAMEORIGIN` if the app frames itself), plus `frame-ancestors` in the CSP
- `Permissions-Policy` turning off what the site does not use, e.g. `camera=(), microphone=(), geolocation=()`
- Remove `X-Powered-By` and server version banners where the framework allows.

### 4. Content-Security-Policy, safely

Inventory every script, style, font, image, frame and fetch origin the site loads (analytics, payments, chat widgets, fonts, CDNs). Write a policy that allows exactly those, and ship it first as `Content-Security-Policy-Report-Only`. Where inline scripts are needed, prefer nonces or hashes over `'unsafe-inline'`; say plainly where the framework makes that hard. Tell me how to switch to the enforcing header once a few days show no violations.

## Done means

- [ ] HTTP redirects to HTTPS in one hop and HSTS is set.
- [ ] Every HTML response sends nosniff, a referrer policy, framing protection and a permissions policy.
- [ ] A Content-Security-Policy that lists every origin the site uses ships in report-only mode, with steps to enforce it.
- [ ] Headers are set in one place, and the site still works on every main page.

## Report back

When you finish, give me:

- what you changed, file by file;
- anything you skipped, and why;
- anything I must do by hand (DNS records, dashboards, accounts, deploys);
- how to check each change on the live site.

One-line version

For agents that can read a URL. It fetches this prompt with your settings applied.

Read https://abacklaunch.com/prompts/security-headers.md and follow it for this project.

3Check the result

When the changes are live, run these free checks. Add your site URL above and each one opens already running on it.

This prompt will not

  • Edit .env files, secrets or API keys, or print their values.
  • Deploy, push, merge or publish anything.
  • Delete data, or run migrations or scripts against a production database.
  • Add tracking, third-party scripts or links to any site I did not ask for.
  • Change copy, design or behaviour that this job does not need.
  • Enable HSTS preload without my confirmation.
  • Switch the CSP to enforcing mode on its own.

It reads your code first, shows you a plan, and waits for your approval before it changes anything.

What you get

  • HTTPS redirects and HSTS on every response
  • The simple security headers, set from one place
  • A Content-Security-Policy built from what your site really loads, rolled out in report-only mode

How to use this prompt

  1. 1

    Describe your stack

    Add your site, framework and host. The prompt adapts; blank fields are left for the agent to work out.

  2. 2

    Paste it into your agent

    Open your project in Claude Code, Cursor, Codex, Copilot, Windsurf or Cline, and paste the prompt or the one-line version.

  3. 3

    Approve the plan

    The agent reads your code, shows you a plan with the files it will touch, and waits. Change anything you disagree with.

  4. 4

    Check the result

    When the changes are live, run the free checks below on your site to confirm each fix.

What the agent does

Security headers are the cheapest protection the production site can have: a few lines of config that stop clickjacking, MIME sniffing, protocol downgrades and many script injections. Set them once, in one place, for every response, and roll out the Content-Security-Policy in report-only mode first so nothing breaks on launch day.

  1. 1. See what is sent today

    Find where response headers are set (framework config, middleware, the current host config, a CDN rule in the repository) and list the headers the homepage, an API route and a static asset send now. Note anything set in two places that could disagree.

  2. 2. HTTPS everywhere

    Every HTTP request should redirect to HTTPS in one hop. Add Strict-Transport-Security: max-age=31536000; includeSubDomains. Only add preload if I confirm every subdomain serves HTTPS, because preloading is hard to undo.

  3. 3. The simple headers

    Set on every HTML response, from one place:

    • X-Content-Type-Options: nosniff
    • Referrer-Policy: strict-origin-when-cross-origin
    • X-Frame-Options: DENY (or SAMEORIGIN if the app frames itself), plus frame-ancestors in the CSP
    • Permissions-Policy turning off what the site does not use, e.g. camera=(), microphone=(), geolocation=()
    • Remove X-Powered-By and server version banners where the framework allows.
  4. 4. Content-Security-Policy, safely

    Inventory every script, style, font, image, frame and fetch origin the site loads (analytics, payments, chat widgets, fonts, CDNs). Write a policy that allows exactly those, and ship it first as Content-Security-Policy-Report-Only. Where inline scripts are needed, prefer nonces or hashes over 'unsafe-inline'; say plainly where the framework makes that hard. Tell me how to switch to the enforcing header once a few days show no violations.

Done means

  • HTTP redirects to HTTPS in one hop and HSTS is set.
  • Every HTML response sends nosniff, a referrer policy, framing protection and a permissions policy.
  • A Content-Security-Policy that lists every origin the site uses ships in report-only mode, with steps to enforce it.
  • Headers are set in one place, and the site still works on every main page.

Questions

Will a Content-Security-Policy break my site?

It can, which is why the prompt ships it as report-only first. The browser reports what the policy would block without blocking it, and you switch it on once the reports are clean.

Is X-Frame-Options still needed with CSP frame-ancestors?

Modern browsers follow frame-ancestors, and sending both covers older ones. The prompt sets both, consistently.

Should I preload HSTS?

Only when every subdomain serves HTTPS and will keep doing so. Preload lists ship in browsers, and removing a site takes months.

Does this prompt add links to Aback Launch to my site?

No. Nothing in the prompt mentions Aback Launch or asks your agent to link to us. The only exception is an optional badge step, which stays off unless you tick it. Some prompt libraries slip their own link into your codebase by default; we think that should always be your choice.

Which coding agents does it work with?

Claude Code, Cursor, Codex, GitHub Copilot, Windsurf, Cline, and any agent that can read your project and edit files. You can copy it as a plain prompt, save it as a Claude Code skill or a Cursor rule, or add it to AGENTS.md.

Is it safe to run on my real codebase?

The prompt makes the agent read first, show a plan and wait for your approval, and it forbids touching secrets, deploying and deleting data. Still review the changes and run your tests before you deploy, as with any change.

Changelog

  • v1.0First version.

Launch your startup on Aback Launch

Get a launch page that search engines and AI assistants can read, a place in the weekly launch list, and a review by a real person. Free to join.