Content-Security-Policy header missing on a Replit app: what to do
Short answer: Your published Replit app is not sending a Content-Security-Policy HTTP response header. That header tells the browser which scripts, styles, and other content the page may load, which helps limit cross-site scripting. On a Static Deployment, add it in your root .replit file and republish. On Autoscale or a Reserved VM, set the header in your application and republish. SniffPup, a free passive security scanner for vibe-coded apps, can check whether a live URL you own sends the header; it does not grade how strict the policy is. Run a free SniffPup scan of your own site after you republish.
Passive, read-only checks only, for a live URL you own or are authorized to test. This is not a source, RLS, or security audit. A score of 100 means no issues were found in our checks, not proof of security. Full fixes free for every critical issue (no critical? one other fix is free).
Home › Guides › Content-Security-Policy header missing on a Replit app: what to do · Last updated · By Ember, SniffPup
What does a missing Content-Security-Policy header mean?
MDN describes the Content-Security-Policy response header as a way to control which resources the browser may load for a page, which helps guard against cross-site scripting. OWASP treats CSP as defense in depth: it can make XSS harder to exploit, but it is not a replacement for safe output encoding and input validation, and you should not rely on it as the only defense.
If the published URL has no Content-Security-Policy header, the browser does not get that extra allowlist. Replit's security checklist tells you to add important security headers to your application, and its back-end checklist lists basic security headers (X-Frame-Options, X-Content-Type-Options, and HSTS). This page covers the Content-Security-Policy header. The same checklist says Replit uses HTTPS by default for all applications; HTTPS is not a substitute for CSP.
How do I add a Content-Security-Policy header on a Replit Static Deployment?
Replit documents custom response headers for Static Deployments in the root .replit file. Add a deployment.responseHeaders entry, then republish. Content-Security-Policy is not in Replit's reserved header list (Accept-Ranges, Age, Allow, Alt-Svc, Connection, Content-Encoding, Content-Length, Content-Range, Date, Location, Server, Set-Cookie, Trailer, Transfer-Encoding, and Upgrade), so you can set it. You can add more than one deployment.responseHeaders entry.
[[deployment.responseHeaders]]
path = "/*"
name = "Content-Security-Policy"
value = "default-src 'self'"This follows Replit's documented format (their example uses Access-Control-Allow-Origin). The value matches the policy in Replit's security checklist example. Changes apply when you republish.
Replit's deployment types page says Autoscale is the default and recommended choice, and it points to advanced Static configuration for response headers, URL rewrites, and redirects. It also notes that Static Deployments are not compatible with Replit Apps created using Agent, because Agent builds full-stack apps that need a backend. If you used Agent, you are probably on Autoscale or a Reserved VM, not Static.
How do I add the header on Autoscale or a Reserved VM?
Replit documents [[deployment.responseHeaders]] in the Static Deployment configuration guide, not as a setting for Autoscale or Reserved VM. For those types, set the Content-Security-Policy HTTP response header in your application. Replit's checklist says to add important security headers to your application, “in index.html or through your back-end.” Then republish so the published URL sends the header.
Replit also suggests asking Agent, “Can you add the security headers to my application?” After any change, confirm the live HTTP response includes Content-Security-Policy. A meta tag in the HTML is not the same as that header.
Can I use a meta tag instead of the HTTP header?
Replit's security checklist shows this example:
<!-- In index.html or through your back-end -->
<meta http-equiv="X-Frame-Options" content="DENY">
<meta http-equiv="X-Content-Type-Options" content="nosniff">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'">OWASP says delivering CSP with the Content-Security-Policy HTTP response header is the preferred way and supports the full feature set, and you should send it in all HTTP responses, not just the index page. A meta http-equiv tag can still apply many CSP rules, but it cannot use framing protections (frame-ancestors), sandboxing, or a CSP violation logging endpoint. MDN also documents that the frame-ancestors directive is not supported in the meta element, and it warns not to set other security headers with meta http-equiv, because that can give a false sense of security.
A check that looks at HTTP response headers, including a free SniffPup scan, will still report the header as missing if it is only in a meta tag. Prefer the HTTP header.
What should I do?
1. Confirm the published URL's response headers
Open your published Replit app (a replit.app address or your own domain) and inspect the HTTP response headers for Content-Security-Policy. Use the browser's developer tools, on the document request. Judge the HTTP response, not only the HTML. A meta tag in the page is not this header.
2. Add the header for your deployment type
In the Publishing tool, under Adjust settings, check the deployment type. For a Static Deployment, add a deployment.responseHeaders entry to the root .replit file, then republish. For Autoscale or a Reserved VM, set the Content-Security-Policy HTTP response header in your application, then republish. Replit documents the .replit response-header format in its Static Deployment configuration guide.
3. Start with a policy that matches what the page loads
Replit's checklist example uses default-src 'self'. OWASP's basic policy is default-src 'self'; frame-ancestors 'self'; form-action 'self' when all resources come from your own origin and you have no inline scripts or styles. A tighter policy can break fonts, images, analytics, or inline scripts you rely on. If you are unsure, OWASP recommends Content-Security-Policy-Report-Only first, then enforce. Avoid adding 'unsafe-inline' or 'unsafe-eval' just to silence errors; MDN and OWASP warn those weaken the protection.
4. Republish and recheck the live header
Replit's Static Deployment docs say you must republish for .replit configuration updates to apply. After an application-level change, republish so the running deployment includes it. Confirm the live HTTP response now includes Content-Security-Policy.
5. Optionally re-check a URL you own
A free SniffPup scan of a live URL you own or are authorized to test is passive and read-only. It checks whether the Content-Security-Policy header is present on the page you enter (on a verified site, paid plans can check more pages: 5 Starter, 25 Pro, 50 Ultimate). It does not grade CSP strictness. It is not a source, RLS, or security audit. A score of 100 means no issues were found in our checks, not proof of security.
Next: Is my Replit app secure?, Vibe-coded app security checklist, How to secure a Windsurf app, Exposed .env or .git files: what to do, and Find exposed API keys on your website.
FAQ
Why is my Replit app missing a Content-Security-Policy header?
Replit's docs show how to add response headers on a Static Deployment in the root .replit file, and they tell you to add security headers to your application (the checklist's HTML example or your back-end). If you have not set Content-Security-Policy in one of those places, the published URL often will not send the header.
I added the meta tag from Replit's checklist. Why does a header check still fail?
A check of HTTP response headers looks for the Content-Security-Policy header itself. A meta http-equiv tag in the HTML is not that header. OWASP calls the HTTP header the preferred way to deliver a policy, and it supports the full feature set. Prefer the header, republish, and recheck the live response headers.
What Content-Security-Policy should I start with?
Replit's security checklist example uses default-src 'self'. That allows same-origin resources and, by default, blocks typical inline scripts. If the app breaks, widen only the directives you need, such as images or fonts from a host you actually use, rather than removing the header. OWASP's basic policy also sets frame-ancestors 'self' and form-action 'self'. OWASP says CSP is an extra layer, not the only XSS defense.
Does a SniffPup scan check how strict my Content-Security-Policy is?
No. The free site scan is passive and read-only on a live URL you own or are authorized to test. It checks whether the Content-Security-Policy HTTP header is present, along with other security headers, on the page you enter (or more pages of a verified site on paid plans). It does not grade CSP strictness, and it cannot see your source or server config. It is not a source, RLS, or security audit. A score of 100 means no issues were found in our checks, not proof of security.
Will adding this header make my Replit app secure?
No. A Content-Security-Policy is one layer. It does not replace keeping secrets out of the browser, testing API routes signed out, or Replit's Security Center scans. A score of 100 on an outside scan means no issues were found in those checks, not proof of security.
Sources: Replit: Static Deployment configuration (response headers in .replit, reserved headers, republish), Replit: Deployment types (Autoscale default; Static headers live in the advanced Static guide; Agent apps are not Static), Replit: Security checklist (add security headers to your application; meta-tag example; HTTPS by default), MDN: Content-Security-Policy header, MDN: frame-ancestors (not supported in a meta element), and OWASP: Content Security Policy Cheat Sheet (header preferred; meta limits; basic policy and Report-Only), checked November 11, 2026. SniffPup facts are from our scanner page.