Guides · Troubleshooting

Why isn't my header or mock working in Chrome?

By Marlon Maniti · Last updated

Short answer: most of the time the page loaded before you saved the rule, the API lives on a host that isn't in your Domains list, or the request comes from somewhere a mock can't reach, such as an iframe or a worker. Open DevHeader from the page you're testing: each rule's status dot and the Debug checklist in the footer tell you which one it is.

Start with the status dot

Every saved header and redirect rule has a small dot next to its On checkbox. It describes the tab you opened the popup from, so open DevHeader from the page you're testing, not from chrome://extensions or a new tab. Hover the dot for the reason:

Dot What it means
Green with a ring, Matched Chrome changed at least one request on this page with this rule.
Green, Applied Chrome has the rule installed, but nothing on this page has matched it yet.
Amber, Reload needed You saved it after the page loaded. Requests the page already made didn't get it.
Amber, Waiting for access DevHeader doesn't have host access yet. Click Allow access in the popup.
Amber, warning Chrome applies it, but the browser may ignore it. The tooltip says why.
Red, Rejected by Chrome Chrome refused the rule, with Chrome's own message. Your other rules still apply.
Grey The rule is off, or Chrome is installing it right now.

The footer sums it up, for example Applied: 2 · Matched: 1.

Open the Debug checklist

Click Debug in the popup's footer. It checks the open tab in order: DevHeader is on, host access is granted, the page loaded after your last change, Chrome accepted every rule, and whether any rule matched on this page. Below that it shows whether the page's host is in your Domains list, and the browser limits that apply to the rules you have.

The DevHeader Debug checklist for the open tab, with a rule saved after the page loaded

The usual causes

You saved after the page loaded. Header and redirect rules apply to requests made after you save, so the page itself and anything it fetched on load didn't get the new rule. Mocks only take effect when a page loads at all. The footer shows Reload needed with a Reload Page button that reloads the tab for you.

The API is on another host. Domains filter each request by its own host, not by the page's. A page on app.example.com that calls api.example.com needs api.example.com in Domains too. The Debug panel always lists this, because it's the most common reason a header never reaches an API.

Matched, but your API call still doesn't have it. Chrome reports that a rule matched on the tab, not which request it matched. The match can be the page itself or its favicon. To check one API call, select it in DevTools → Network and look under Request Headers, or in the DevHeader panel open it and choose Request headers.

Chrome rejected a regex. Chrome matches redirects with its RE2 engine, which has no lookaheads, lookbehinds or backreferences. DevHeader checks your pattern with Chrome before saving and shows the reason on the row; a rule Chrome refuses later turns red with Chrome's message.

CORS with cookies. Access-Control-Allow-Origin: * doesn't work for requests sent with credentials. If you also set Access-Control-Allow-Credentials: true, the rule's dot turns amber. Use your page's exact origin instead of *.

If it's a mock

Mocks run inside the page and replace fetch and XMLHttpRequest responses, so they work differently from header rules:

  • Did it fire? Look at the rule in the popup's Mocks tab. Mocked N× counts the responses it returned on this page since it loaded; hover it for the last URL. Your code can also check response.headers.get("x-devheader-mock"), which is set to the rule's name on every mocked response.
  • Don't look in the Network panel. A mocked request never reaches the network, so it isn't listed in Chrome's Network panel or DevHeader's Live Status. If a request a mock rule matches shows up there, DevHeader marks it: Mock after reload (your mocks changed since the page loaded) or Not mocked (it really went to the server).
  • Check the status badge next to your mock rules. Anything other than Active mocks (N) names the fix: Scripts disabled means turning on Allow User Scripts for DevHeader in chrome://extensions (Chrome 138+), No domain access means granting host access, and Paused means DevHeader is off.
  • Iframes and workers aren't mocked. Requests from a cross-origin iframe, a Web Worker or a service worker skip the mock. Header rules still apply to them.

Limitations

  • Chrome reports matches per tab, not per request, so Matched can't prove a particular API call got the header. Check the request itself.
  • Matches only cover the tab you opened DevHeader from, since it was last loaded.
  • Mocks don't reach iframes, Web Workers or service workers, and need Chrome 138+ with Allow User Scripts on.

FAQ

It works in one tab but not another. Rules are the same everywhere, but the dot and the checklist only describe the tab you opened DevHeader from. Open it from the tab that's failing.

The page is not in my Domains list. Is that the problem? Not necessarily. Domains filter each request's own host, so a page outside the list can still have its API calls changed when the API's host is listed. The Debug panel shows this as information, not a warning.

Sources

Try DevHeader

DevHeader is free, keeps every rule on your machine, and only touches sites you grant it access to. Install it from the Chrome Web Store or Edge Add-ons.

Related guides