PatchPaste · Guides
Last updated 1 November 2026
How do I add security headers to my Lovable or Bolt app?
Scan your live app free. It reads the headers your published site actually sends (Content-Security-Policy, Strict-Transport-Security, X-Frame-Options or frame-ancestors, X-Content-Type-Options and Referrer-Policy) and also checks the JavaScript your site sends for secret keys. No login, no code access. Most scans take under 30 seconds.
Content-Security-Policy last, and in report-only mode first, because it's the one header that can break your app.Missing headers are rarely the most urgent problem in an AI-built app. A leaked secret key or a Supabase table anyone can read matters far more. Fix those first, then come back to headers.
What each header does
| Header | What it stops | Starter value |
|---|---|---|
Strict-Transport-Security (HSTS) | Browsers falling back to plain HTTP | max-age=63072000; includeSubDomains |
X-Content-Type-Options | The browser guessing a file's type and running it as a script | nosniff |
X-Frame-Options or CSP frame-ancestors | Another site loading yours in a hidden frame to trick clicks (clickjacking) | DENY, or frame-ancestors 'none' |
Referrer-Policy | Full page URLs leaking to other sites | strict-origin-when-cross-origin |
Content-Security-Policy (CSP) | Injected scripts loading or sending data to places you didn't allow | Build it for your app (see step 3) |
What your builder sends by default
We checked the response headers of a few live apps on 31 October and 1 November 2026. This is what we saw, not a promise from the platforms, and it can change:
- Lovable (
*.lovable.app): HSTS,X-Content-Type-Options: nosniffandReferrer-Policy, but no Content-Security-Policy and no X-Frame-Options. - Base44 (
*.base44.app): HSTS, nosniff, Referrer-Policy andX-Frame-Options: DENY, but no Content-Security-Policy. - Bolt (
*.bolt.host): on the Bolt-hosted apps we checked on 31 October 2026, HSTS but no CSP, X-Frame-Options or nosniff.
So a scan of a Lovable app will usually flag CSP and framing protection, and a Base44 app will usually flag CSP. Check your own site rather than trusting this list:
curl -sI https://your-app.lovable.app/ | grep -iE 'strict-transport|x-content-type|x-frame|content-security|referrer-policy'
Only run this against sites you own.
Step 1: find out who serves your app
Headers are added by the server that answers the request. Asking the AI builder to “add security headers” often creates a vercel.json or _headers file, but that file does nothing unless Vercel or Netlify is the host actually serving the site.
- Published on Lovable, Base44 or Bolt hosting: their docs don't describe a custom header setting (we checked Lovable's deploy and custom domain docs on 1 November 2026). Use step 2b or 2c.
- Deployed to Vercel or Netlify (for example through GitHub sync): use step 2a.
Step 2a: Vercel or Netlify
Vercel: add a vercel.json to the project root.
{
"headers": [
{
"source": "/(.*)",
"headers": [
{ "key": "Strict-Transport-Security", "value": "max-age=63072000; includeSubDomains" },
{ "key": "X-Content-Type-Options", "value": "nosniff" },
{ "key": "X-Frame-Options", "value": "DENY" },
{ "key": "Referrer-Policy", "value": "strict-origin-when-cross-origin" }
]
}
]
}Netlify: add a plain text file called _headers to the folder that gets published (for a Vite app that's usually public/, so it ends up in dist/).
/* Strict-Transport-Security: max-age=63072000; includeSubDomains X-Content-Type-Options: nosniff X-Frame-Options: DENY Referrer-Policy: strict-origin-when-cross-origin
Netlify's docs note that _headers only applies to files Netlify serves itself, not to responses from functions or proxied content.
Step 2b: Cloudflare in front of a custom domain
If your custom domain's DNS runs through Cloudflare with the proxy turned on, a Response Header Transform Rule can add the same headers to every response, while the app stays on your builder's hosting. Check with curl -I afterwards that the headers really arrive on your domain.
Step 2c: a CSP meta tag (partial fix only)
You can put <meta http-equiv="Content-Security-Policy" content="..."> in index.html. It does limit where scripts load from and where the page can send data. But browsers ignore frame-ancestors and report-only mode in a meta tag, and HSTS, nosniff and X-Frame-Options can't be set this way at all. So it doesn't stop clickjacking.
Step 3: add a Content-Security-Policy without breaking your app
A CSP lists every place your page may load code from or talk to. Forget one and that part of the app stops working: a login that does nothing, a Supabase call that fails, a Stripe form that never appears.
- Start with report-only. Send
Content-Security-Policy-Report-Onlyinstead ofContent-Security-Policy. Vercel and Netlify both recommend this. It shows what would be blocked without blocking it. - List what your app really uses. Usually
'self', your Supabase project URL inconnect-src(https://<project>.supabase.co, pluswss://<project>.supabase.coif you use Realtime), and Stripe (https://js.stripe.com) if you take payments, plus your font, image and analytics hosts. - Click through everything while the browser console is open: sign up, log in, the main feature, checkout. Copy any CSP warnings back to your AI builder.
- Switch to the real header once a full click-through shows no warnings.
A starting point for a Vite app on Supabase, to adjust before you use it:
default-src 'self'; script-src 'self'; connect-src 'self' https://<project>.supabase.co wss://<project>.supabase.co; img-src 'self' data: https:; style-src 'self' 'unsafe-inline'; font-src 'self' data:; frame-ancestors 'none'; base-uri 'self'; form-action 'self'
Vercel's advice is to avoid 'unsafe-inline' and 'unsafe-eval' where you can, and to name specific domains rather than *. A policy full of * looks like a CSP but does very little.
Check it worked
Run the curl -I command again on your live URL, then run a free PatchPaste scan. Scans are free to rerun, so you can check again after every change.
Before launch, run the full Lovable/Bolt pre-launch checklist. Also see is my Lovable app secure?, are VITE_ variables secret? and is my Stripe secret key exposed?
Security headers FAQ
Why does my scan say security headers are missing?
Security headers are sent by whatever hosts your app, not by your React code. On the Lovable apps we checked on 1 November 2026, HSTS, nosniff and Referrer-Policy were sent, but Content-Security-Policy and X-Frame-Options were not. So a scan of a Lovable app will usually flag those two.
Can I add security headers on Lovable hosting?
Lovable's deploy and custom domain docs don't describe a setting for custom headers (we checked on 1 November 2026). You can host the same build on Vercel or Netlify, or put Cloudflare in front of your custom domain and add the headers with a rule there.
Will a vercel.json or _headers file work on Lovable or Bolt hosting?
No. Those files only work when Vercel or Netlify is the host actually serving your site. If your AI builder created one but your app is still on its own hosting, the file does nothing.
Can I set a Content-Security-Policy with a meta tag?
Partly. A CSP meta tag in index.html can limit where scripts load from and where the page sends data. But browsers ignore frame-ancestors and report-only mode in a meta tag, and HSTS, nosniff and X-Frame-Options can't be set that way. So it doesn't stop clickjacking.
Will a Content-Security-Policy break my app?
It can. If you leave out a place your app loads code from or talks to, that part stops working, for example Supabase calls or a Stripe form. Start with Content-Security-Policy-Report-Only, click through the whole app with the console open, and only switch to the real header when there are no warnings.
Are missing headers a serious problem?
Usually less serious than a leaked secret key or a Supabase table anyone can read. Fix those first. Headers are extra protection that make some attacks harder.
Does PatchPaste check security headers?
Yes. The free scan reads the headers your live site actually sends: Content-Security-Policy, Strict-Transport-Security, X-Frame-Options or CSP frame-ancestors, X-Content-Type-Options and Referrer-Policy. It also searches the JavaScript your site sends for secret keys.
Check your app for free
Paste your live URL for a free A to F report with every problem in plain English. Fix prompts for that report are a one-off £9 (or £29 for 10 reports). Scans are free to rerun, so you can check again after you add your headers and redeploy.
Want to see one first? View a sample report.
Sources (read 1 Nov 2026): MDN: Content-Security-Policy, Vercel: vercel.json headers, Vercel: security headers, Netlify: custom headers, Netlify: Content Security Policy. Default header observations: PatchPaste's own read-only header checks of public Lovable, Base44 and Bolt apps on 31 October and 1 November 2026.