Guide

How to disable Content Security Policy in Chrome

To turn off a site’s Content Security Policy while you develop, remove the Content-Security-Policy response header for that site. Headerbench’s Remove Content Security Policy preset does it in one click. A policy set in a <meta> tag inside the page still applies.

Remove the CSP header in Headerbench

  1. Create a profile named No CSP.
  2. Open Response headers and click the Remove Content Security Policy preset. It adds two Remove rows: Content-Security-Policy and Content-Security-Policy-Report-Only.
  3. Open Filters and add an include filter of type Domain with the site you are working on, for example staging.example.com.
  4. Leave Request types on All types. The policy arrives with the page itself, so page loads and iframes must be covered.
  5. Open the site, turn the profile on in the popup and allow access when Chrome asks.
  6. Reload. The Refused to load… and Refused to execute… errors should be gone from the Console.
Profile         No CSP
Response headers
  Remove  Content-Security-Policy
  Remove  Content-Security-Policy-Report-Only
Filters
  Include  Domain    staging.example.com

Development and debugging only. CSP is the page’s defence against injected scripts. Without it, a site you are logged in to is easier to attack. Keep the domain filter, and in the popup’s menu for the profile choose This tab only or Pause after 1 hour.

Override the policy instead of removing it

Often you only need one source allowed, such as your local dev server. Instead of the preset, add a Set row for Content-Security-Policy with the policy you want, which replaces the server’s:

Set  Content-Security-Policy
     default-src 'self'; script-src 'self' http://localhost:5173; connect-src 'self' ws://localhost:5173

This is also a safe way to try a new policy before you ship it: set Content-Security-Policy-Report-Only to the candidate policy and the Console lists every violation without blocking anything.

Check that it worked

  • The CSP violation errors are gone from the Console after a reload.
  • Applied on this tab lists both remove rows against the page load. Test a URL with request type Page (document) shows the same.
  • If violations remain, run document.querySelector('meta[http-equiv="Content-Security-Policy"]') in the Console. A result means the policy is in the page’s HTML, where a header rule cannot reach it.

Chrome DevTools does not always show headers changed by an extension. If the Network panel shows the old value, trust the server’s echo or the popup’s Applied on this tab, which asks Chrome what it actually changed.

What removing CSP does not change

  • A policy in a <meta http-equiv> tag.
  • Framing: to embed a page in an iframe on localhost, also remove X-Frame-Options. Its CSP counterpart, frame-ancestors, goes with the header you already removed.
  • Cross-origin isolation headers such as Cross-Origin-Embedder-Policy and Cross-Origin-Opener-Policy, which are separate headers with their own rows.
  • Chrome’s own pages and the Chrome Web Store, which extensions cannot change.

Troubleshooting

If nothing changes, check that the profile is on for this tab and that the filter matches the page’s host, not only its API. For iframes from another host, add that host to the filters. Chrome also needs access to the page that loads the frame:

Chrome applies header and redirect rules only when Headerbench has access to the request’s site and to the page that sends the request, its initiator. A call to embed.example.com from an app on staging.example.com needs both. Without the page, Chrome skips the rule without an error. The popup shows a Grant button when the current page is missing, and Test a URL has a Sent from page field that checks the pair.

Without an extension

  • DevTools can edit the header for one tab: in the Network panel, right-click the page request, choose Override headers and change the policy. It needs a local overrides folder and works while DevTools is open.
  • In automated tests, Playwright’s bypassCSP: true context option and Puppeteer’s page.setBypassCSP(true) ignore the policy.
  • Chrome has no setting to turn CSP off for normal browsing.

Related guides