Skip to content
ShipCheck
Guides

Security headers for Lovable, Bolt, Vercel and Netlify apps: what to set and how

Updated 31 October 2026

Security headers are short instructions your server sends with every page. They tell the browser to always use HTTPS, which scripts may run, and whether other sites can put your app in a frame. Your React code can't set them. Whatever serves your files sets them: Vercel, Netlify, Lovable or Bolt hosting, or a CDN in front.

Check your own app for this, free.

Paste your live URL. ShipCheck looks for leaked API keys in your page and JavaScript, exposed files like /.env and /.git, missing security headers, SSL certificate problems, domain expiry (custom domains only) and what Google sees without running JavaScript. You'll see your score without signing up.

See an example report

Short answer

Set these six headers for every path. On Vercel, use headers in vercel.json (or headers() in next.config for Next.js). On Netlify, use a _headers file in your publish folder or [[headers]] in netlify.toml. Lovable and Bolt hosting don't document a setting for custom headers, so check what they already send with curl -I. If something's missing, publish the same build to Vercel or Netlify, or add the headers at a CDN in front of your custom domain. Roll out the Content-Security-Policy last, in report-only mode first, because it's the one that can break your app.

Which headers matter

  • Strict-Transport-Security (HSTS): browsers always use HTTPS for your domain, so nobody on public Wi-Fi can downgrade a visitor to plain HTTP. Start with max-age=31536000; includeSubDomains. Only add preload if every subdomain serves HTTPS and you plan to submit the domain to the preload list, which is hard to undo.
  • Content-Security-Policy (CSP): lists where scripts, styles, images and API calls may come from. If an AI-written component renders user input unsafely, a good CSP can stop the injected script from running. This one needs care (see below).
  • X-Frame-Options: DENY or CSP frame-ancestors 'none': stops other sites loading your app in an invisible frame and tricking users into clicking (clickjacking). Use SAMEORIGIN or frame-ancestors 'self' if you frame your own pages. Modern browsers prefer frame-ancestors, and sending both is fine.
  • X-Content-Type-Options: nosniff: stops browsers from guessing file types, so an uploaded file can't be run as a script.
  • Referrer-Policy: strict-origin-when-cross-origin: other sites see only your domain, not full URLs that might contain tokens, emails or search terms. (This is also the browser default when no policy is set. Setting it explicitly makes sure an older or embedded browser doesn't fall back to something looser.)
  • Permissions-Policy: switches off browser features you don't use, for example camera=(), microphone=(), geolocation=(). Check your code first: if the app records audio or uses location, leave that feature out of the list.

Skip X-XSS-Protection. Current browsers ignore it, and a CSP does that job properly.

Vercel

Any framework (Vite, Lovable or Bolt exports, static sites): vercel.json

Put vercel.json in your project root. The /(.*) source matches every path (Vercel docs: headers):

{
  "headers": [
    {
      "source": "/(.*)",
      "headers": [
        { "key": "Strict-Transport-Security", "value": "max-age=31536000; includeSubDomains" },
        { "key": "X-Content-Type-Options", "value": "nosniff" },
        { "key": "X-Frame-Options", "value": "DENY" },
        { "key": "Referrer-Policy", "value": "strict-origin-when-cross-origin" },
        { "key": "Permissions-Policy", "value": "camera=(), microphone=(), geolocation=()" },
        { "key": "Content-Security-Policy-Report-Only", "value": "default-src 'self'; connect-src 'self' https://YOUR-PROJECT.supabase.co; img-src 'self' data: https:; style-src 'self' 'unsafe-inline'; frame-ancestors 'none'; base-uri 'self'; form-action 'self'" }
      ]
    }
  ]
}

A Vite single-page app on Vercel usually needs a rewrite to /index.html as well, so keep any rewrites already in the file. Vercel often sends an HSTS header already (check with curl -I). Setting it yourself makes the value explicit.

Next.js (v0, Cursor): next.config

// next.config.ts
const securityHeaders = [
  { key: "Strict-Transport-Security", value: "max-age=31536000; includeSubDomains" },
  { key: "X-Content-Type-Options", value: "nosniff" },
  { key: "X-Frame-Options", value: "DENY" },
  { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
  { key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=()" },
];

const nextConfig = {
  async headers() {
    return [{ source: "/(.*)", headers: securityHeaders }];
  },
};

export default nextConfig;

This works wherever Next.js runs, not only on Vercel (Next.js docs: headers). For a strict CSP with nonces, Next.js recommends setting it in middleware instead (Next.js CSP guide). A plain static CSP in headers() is a fine start.

Netlify (and Bolt apps published to Netlify)

Netlify reads a plain text file called _headers from the folder it publishes. For a Vite app, put it in public/ so the build copies it into dist/:

/*
  Strict-Transport-Security: max-age=31536000; includeSubDomains
  X-Content-Type-Options: nosniff
  X-Frame-Options: DENY
  Referrer-Policy: strict-origin-when-cross-origin
  Permissions-Policy: camera=(), microphone=(), geolocation=()
  Content-Security-Policy-Report-Only: default-src 'self'; connect-src 'self' https://YOUR-PROJECT.supabase.co; img-src 'self' data: https:; style-src 'self' 'unsafe-inline'; frame-ancestors 'none'; base-uri 'self'; form-action 'self'

Or use netlify.toml in the repo root:

[[headers]]
  for = "/*"
  [headers.values]
    Strict-Transport-Security = "max-age=31536000; includeSubDomains"
    X-Content-Type-Options = "nosniff"
    X-Frame-Options = "DENY"
    Referrer-Policy = "strict-origin-when-cross-origin"
    Permissions-Policy = "camera=(), microphone=(), geolocation=()"

One catch from Netlify's docs: these headers only apply to files Netlify serves itself. Pages made by functions, edge functions or server-side rendering, and proxied content, have to send their own headers. If a header shows up on / but not on an SSR route, that's why.

Lovable hosting

Lovable's hosting docs cover HTTPS, custom domains and access control, but don't describe any setting, file or prompt for adding your own response headers. So:

  1. Run the curl -I check below against your published URL to see what Lovable already sends. Write down the values before you change anything.
  2. Lovable's optional Trust center (off by default, in Project settings → Publishing) publishes security checks Lovable verified for your live app. It reports what it observed. It isn't a place to edit headers.
  3. If you need headers Lovable doesn't send, you have two options. Put a CDN you control in front of your custom domain (for example Cloudflare response header rules). Or publish the same build to Vercel or Netlify, which Lovable documents in deploying outside Lovable, and use the config above.

Asking Lovable's AI to "add security headers" usually produces a <meta http-equiv="Content-Security-Policy"> tag in index.html. That can limit scripts and connections, but browsers ignore frame-ancestors and report-only mode in a meta tag, and HSTS, nosniff, Referrer-Policy as a real header and X-Frame-Options can't be set from HTML at all.

Bolt hosting

Bolt publishes to its own hosting (Bolt Cloud) by default. Bolt's hosting docs don't describe a custom headers setting either. Your options:

  • Switch the project to Netlify hosting. Bolt supports this in Project settings → Domains & Hosting → Hosting Provider, while the project is unpublished and your Netlify account is connected (Bolt: Netlify for hosting). Then add public/_headers as above.
  • Stay on Bolt hosting and test with curl -I. If something's missing, add the headers at a CDN in front of your custom domain.

Rolling out a Content-Security-Policy without breaking your app

  1. Start with Content-Security-Policy-Report-Only and the same value. Nothing gets blocked yet. The browser console lists what would be blocked.
  2. Click through the app: sign in, load data, pay, upload. Add each source you really use: your Supabase URL in connect-src (plus wss://YOUR-PROJECT.supabase.co if you use Realtime), https://js.stripe.com in script-src and frame-src for Stripe, Google Fonts in style-src and font-src, your analytics domain, and so on.
  3. When the console is clean, rename the header to Content-Security-Policy.
  4. Don't "fix" errors with script-src * or 'unsafe-eval'. That switches off most of the protection.

How to test: curl -I

curl -sI https://your-app.com | grep -iE \
  'strict-transport|content-security|x-frame|x-content-type|referrer-policy|permissions-policy'

# also check a deep link and plain http
curl -sI https://your-app.com/dashboard | grep -iE 'content-security|x-frame'
curl -sI http://your-app.com | grep -iE '^(HTTP|location)'
  • Each header you set should appear on / and on a deep link. A missing one on a deep link usually means the path pattern is wrong, or (on Netlify) the route is rendered by a function.
  • The plain http:// request should return a 301 or 308 with a location: https://… line. The full check and what each host does: force HTTP to HTTPS.
  • Changes only apply after you redeploy or republish. Test the URL your visitors use, including the custom domain, not just the preview URL.

Checklist

  1. Run curl -I on your live URL and note what's already sent.
  2. HSTS, nosniff, X-Frame-Options (or frame-ancestors), Referrer-Policy and Permissions-Policy are set for every path.
  3. CSP is in report-only mode, the console is clean, then it's enforced.
  4. Vercel: vercel.json headers or next.config headers(). Netlify: _headers or netlify.toml, with SSR and function routes setting their own.
  5. Lovable or Bolt hosting: headers checked with curl, and a CDN or Vercel/Netlify used for anything missing.
  6. http:// redirects to https://.
  7. Re-check after big AI edits or a host change.

Headers are one item on the list. For the rest (keys, Supabase RLS, exposed files), see the pre-launch security checklist and source maps in production.

What ShipCheck checks about headers

The free scan reads the response headers of your homepage (the final URL after redirects) and reports:

  • no Content-Security-Policy header (medium)
  • no Strict-Transport-Security header when the site is on HTTPS (medium)
  • no X-Frame-Options and no frame-ancestors rule in the CSP (low)
  • X-Content-Type-Options missing or not set to nosniff (low)
  • no Referrer-Policy header (low)
  • no Permissions-Policy header (info)

It also checks whether http:// redirects to https://. Each finding comes with a fix prompt you can paste into your AI builder. What it doesn't do: it checks that each header is present, not whether your CSP is strict (a policy full of * still counts as present). It only looks at the homepage, not deep links. And it doesn't count Content-Security-Policy-Report-Only, so you'll keep seeing the CSP finding until you switch to the enforcing header. Paid plans re-scan automatically, weekly on Solo ($12/mo) or daily on Builder ($29/mo), so a host change that drops your headers gets caught.

FAQ

Which security headers should my web app send?

At minimum: Strict-Transport-Security (max-age=31536000; includeSubDomains), X-Content-Type-Options: nosniff, X-Frame-Options: DENY or a CSP frame-ancestors rule, Referrer-Policy: strict-origin-when-cross-origin, a Permissions-Policy that disables features you don't use, and a Content-Security-Policy rolled out in report-only mode first.

How do I add security headers on Vercel?

Add a headers array to vercel.json with source "/(.*)" and a list of key/value pairs. For Next.js you can instead return the same list from async headers() in next.config. Redeploy, then check with curl -I.

How do I add security headers on Netlify?

Add a _headers file to your publish directory (for Vite apps, put it in public/ so it's copied to dist/), or use [[headers]] tables in netlify.toml. Netlify only applies these to files it serves itself, so SSR pages, functions and proxied content must send their own headers.

Can I set custom security headers on Lovable hosting?

Lovable's hosting docs don't describe a setting for custom response headers. Check what your published app already sends with curl -I. For anything missing, put a CDN you control in front of your custom domain, or publish the build to Vercel or Netlify and set headers there. A CSP meta tag in index.html helps a little, but it can't set frame-ancestors, HSTS or the other headers.

Can I set security headers on Bolt hosting?

Bolt's hosting docs don't describe a custom headers setting. You can switch the project to Netlify hosting in Project settings → Domains & Hosting and use a _headers file, or add headers at a CDN in front of your custom domain. Always confirm with curl -I on the live URL.

Does ShipCheck check security headers?

Yes. The free scan reads your homepage's response headers and flags a missing Content-Security-Policy, missing HSTS on HTTPS sites, no X-Frame-Options or CSP frame-ancestors, X-Content-Type-Options not set to nosniff, and missing Referrer-Policy and Permissions-Policy headers. It also checks the http to https redirect. It checks that headers are present, not how strict your CSP is, and it doesn't count a report-only CSP.

Run the same checks on your app.

A free scan takes under a minute. No card, and no sign-up to see your score and the list of issues.

See an example report