Guide · Security headers · Updated
How to Add Security Headers to Your Lovable, Bolt or v0 App (Fix Missing CSP and Clickjacking Warnings)
You ran a scan on your app and it says "No Content-Security-Policy" or "Page can be embedded in other sites". Your app works fine, so what does that mean, and how do you fix it when you never wrote a server? This guide explains each header in plain words, shows where it goes on Lovable, Bolt, Netlify, Vercel and Next.js, and how to check your live app after.
1. The quick answer
Security headers are short notes your host sends with every page. They tell the browser how to protect your users. They are not set in your React code. They come from whatever serves your site: Netlify, Vercel, Cloudflare, or your builder's own hosting.
- Find out where your app is hosted.
- Add the four easy headers (HSTS, X-Frame-Options, X-Content-Type-Options, Referrer-Policy) in that host's config file.
- Add a Content-Security-Policy last, in Report-Only mode first, so nothing breaks.
- Redeploy and check your live app again.
Headers matter, but they are not the biggest risk. If you have not checked for leaked API keys or open database tables yet, do that first.
2. The five headers and what they do
| Header | What it does | A good starting value |
|---|---|---|
| Strict-Transport-Security (HSTS) | Tells browsers to always use HTTPS for your site. | max-age=31536000; includeSubDomains |
| Content-Security-Policy (CSP) | Lists which scripts, styles, images and connections your pages may load. Limits the damage from an injected script. | Built from what your app loads (see below) |
| X-Frame-Options | Stops other sites from showing your app inside a hidden frame (clickjacking). | DENY (or CSP frame-ancestors 'none') |
| X-Content-Type-Options | Stops the browser from guessing file types. | nosniff |
| Referrer-Policy | Keeps full URLs (which can hold tokens) from leaking to other sites. | strict-origin-when-cross-origin |
Clickjacking is when another site loads your app in an invisible frame and tricks people into clicking your buttons. MDN says CSP frame-ancestors 'none' works like X-Frame-Options: DENY. Next.js docs note that frame-ancestors has replaced X-Frame-Options and has better support in modern browsers. Setting both is fine.
Sources: Next.js: headers · MDN: CSP frame-ancestors · Vercel: Content Security Policy
3. Where to add them (it depends on your host)
Lovable (built-in hosting)
Lovable's docs do not describe a setting for custom response headers. When we checked a few live .lovable.app sites on October 27, 2026, they already sent HSTS, X-Content-Type-Options and Referrer-Policy, but no Content-Security-Policy and no X-Frame-Options. So a scan of a Lovable app will usually flag those two. Your options:
- Sync to GitHub and deploy on Netlify or Vercel. Lovable's Git sync keeps your code in your own repo with two-way sync, so you can keep editing in Lovable and deploy anywhere. Then use the Netlify or Vercel steps below.
- Use Cloudflare in front of your custom domain. Cloudflare's Response Header Transform Rules can add headers to every response.
- A CSP meta tag in index.html is a partial fix. It can limit scripts, but MDN says
frame-ancestorsdoes not work in a meta tag, so it will not stop clickjacking.
Bolt
Bolt publishes to Bolt hosting by default, and Bolt's help center shows how to publish to Netlify instead or switch between them. On Netlify, follow the Netlify steps. Bolt projects are usually Vite apps, so the _headers file goes in the public/ folder. If you stay on Bolt hosting, add the file, publish, and check your live site to see if the headers show up.
Netlify (and Bolt apps on Netlify)
Netlify reads a plain text file called _headers in the folder it publishes, or a [[headers]] table in netlify.toml. For a Vite app, put _headers in public/ so the build copies it over:
/*
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin
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'Netlify says custom headers only apply to files it serves from its own storage. Pages made by functions, edge functions or server rendering must send their own headers.
Vercel (v0, Cursor and other apps on Vercel)
Add a headers list to vercel.json at the root of your project. /(.*) matches every route:
{
"headers": [
{
"source": "/(.*)",
"headers": [
{ "key": "Strict-Transport-Security", "value": "max-age=31536000; includeSubDomains" },
{ "key": "X-Frame-Options", "value": "DENY" },
{ "key": "X-Content-Type-Options", "value": "nosniff" },
{ "key": "Referrer-Policy", "value": "strict-origin-when-cross-origin" }
]
}
]
}Next.js (common for v0 and Cursor)
You can also set headers in next.config.js with an async headers() function that returns a source like /:path* and a list of key and value pairs. The Next.js docs include ready examples for HSTS, X-Frame-Options, X-Content-Type-Options and Referrer-Policy.
Sources: Lovable: Git sync · Bolt: Netlify for hosting · Netlify: Custom headers · Vercel: vercel.json headers · Next.js: headers · Cloudflare: Response Header Transform Rules
4. Add a Content-Security-Policy without breaking your app
The CSP is the one header that can break things. If it forgets a service your app uses, that part stops working: a login button that does nothing, a Supabase call that fails, a payment form that never shows up.
- Start with Report-Only. Send
Content-Security-Policy-Report-Onlywith your policy. Vercel and MDN both suggest this: it reports what would be blocked but does not block it. - List what your app loads. Your own site (
'self'), your Supabase URL inconnect-src, plus Stripe, fonts, analytics or image hosts if you use them. - Click through everything. Sign up, log in, the main feature, checkout. Open the browser console and copy any CSP warnings back to your AI builder.
- Switch to the real header (
Content-Security-Policy) once a full click-through shows no warnings.
Vercel's advice: avoid unsafe-inline and unsafe-eval where you can, and list specific domains instead of *. A CSP with * in it looks like a policy but does very little.
Sources: Vercel: CSP best practices · MDN: Content-Security-Policy-Report-Only
5. Check your live app in 60 seconds
- Fastest: paste your live link above. VibeCheck reads the response headers your live home page sends and flags missing HSTS, Content-Security-Policy, X-Frame-Options (or frame-ancestors), X-Content-Type-Options and Referrer-Policy. It also checks that your site uses HTTPS and that
http://redirects tohttps://. - In your browser: open your live app, open dev tools (F12), go to the Network tab, reload, click the first request (your page) and look at Response Headers.
- In a terminal: run
curl -I https://yourapp.comand read the list. - Check the live domain, not the preview. Headers set on one host do not follow you to another. If you moved hosting, check your custom domain again.
6. Copy-paste fix prompts
Paste the matching prompt into Lovable, Bolt, v0, Replit or Cursor. Then redeploy and check your live app again.
Add these security headers to every page of my live site, using my hosting platform's config (public/_headers on Netlify, vercel.json on Vercel, or the headers() function in next.config.js for Next.js): Strict-Transport-Security: max-age=31536000; includeSubDomains, X-Frame-Options: DENY, X-Content-Type-Options: nosniff, Referrer-Policy: strict-origin-when-cross-origin. Tell me which file you changed and how to confirm the headers show up on my live site after I redeploy.
Add a Content-Security-Policy to my app as an HTTP response header (not only a meta tag). First list every outside service my app loads from (for example my Supabase URL, Stripe, Google Fonts, analytics, image hosts). Build the policy from that list only, include frame-ancestors 'none', and do not use * or unsafe-eval. Start it as Content-Security-Policy-Report-Only. Then tell me how to test my sign-up, login, main feature and checkout, read the CSP warnings in the browser console, and switch to the enforcing header when there are none.
My app is hosted on Lovable and I need custom security headers (Content-Security-Policy and X-Frame-Options). Help me sync this project to GitHub and deploy it on Netlify (or Vercel) with a public/_headers file (or vercel.json) that sets the headers, plus the rewrite my app needs so page routes do not return 404 on refresh. Keep my environment variables working and tell me the exact steps in order.
7. Check it for me
Paste your link into VibeCheck. In about 10 seconds it checks your live app's security headers and HTTPS, plus the bigger risks: leaked API keys in your JavaScript, open Supabase tables, your page title and description, sitemap and broken links.
It is a public, read-only check. It never asks for your source code or login.
Pricing: the problems list is free (just add your email). The $9 fix report gives you a copy-paste fix prompt for every problem found, or get the $29 10-pack (10 fix reports to use any time). No subscription.
VibeCheck checks whether each header is there. It does not judge how strict your Content-Security-Policy is, so still test your policy with Report-Only first.
8. FAQ
Do I really need security headers on my vibe-coded app?
They are not the first thing to fix. A leaked secret key or an open database table is much worse. But headers are free, take a few minutes, and close real holes: Content-Security-Policy limits which scripts can run, and X-Frame-Options or frame-ancestors stops other sites from hiding your app in a frame to trick clicks. Add them before you launch.
Can I add security headers to an app hosted on Lovable?
Lovable's docs do not describe a setting for custom response headers on its built-in hosting. When we checked a few live .lovable.app sites on October 27, 2026, they already sent HSTS, X-Content-Type-Options and Referrer-Policy, but no Content-Security-Policy and no X-Frame-Options. To add those, you can sync your project to GitHub and deploy it on Netlify or Vercel, or put Cloudflare in front of your custom domain and add the headers there.
Can I put my Content-Security-Policy in a meta tag instead?
Partly. A CSP meta tag in index.html can limit scripts and connections. But MDN says frame-ancestors is not supported in a meta tag, and neither is Report-Only mode. So a meta tag cannot stop clickjacking. For that you need a real HTTP header.
Will a Content-Security-Policy break my app?
It can, if it forgets a service your app uses, like Supabase, Stripe, Google Fonts or analytics. That is why Vercel and MDN suggest starting with Content-Security-Policy-Report-Only. It only reports what would be blocked. Click through your whole app, fix the warnings in the browser console, then switch to the real header.
What is the difference between X-Frame-Options and frame-ancestors?
Both stop other sites from loading your app in a frame. X-Frame-Options: DENY is the older header. CSP frame-ancestors 'none' is the newer way, and Next.js docs say it has better support in modern browsers. Setting both is fine and covers older browsers too.
I added headers but my scan still says they are missing. Why?
Usually the file is in the wrong place or the site was not redeployed. On Netlify, the _headers file must end up in the folder Netlify publishes (for Vite apps, put it in public/). Netlify also says its custom headers do not apply to pages made by functions or server rendering. On Vercel, vercel.json must be at the root of the project. Redeploy, then check your live site again.
More questions? See the VibeCheck FAQ. Related guides: Is my Lovable app safe? · Is my Bolt app secure? · Is my v0 app secure? · Vibe coding security checklist · Site says "Not secure"?.