HeaderDial › Guides

Redirect a URL to localhost in Chrome, Edge or Firefox

To make the browser load a production file from your machine, add a URL redirect in HeaderDial: put https://cdn.example.com/app/ on the left and http://localhost:3000/ on the right. Every request whose URL contains the left-hand text goes to the same URL with that text replaced, so https://cdn.example.com/app/main.js?v=7 loads from http://localhost:3000/main.js?v=7. The site, its HTML and its other requests stay as they are. That makes it a quick way to try a local build of one bundle against real production data, or to point a page at a different API version.

Steps

  1. Click the HeaderDial icon. If the site-access banner appears, choose Allow on all sites or Only <current host>. Without access to the site, nothing is redirected.
  2. Click + URL redirect. Keep the type on Replace.
  3. On the left, type the part of the URL to swap, for example https://cdn.example.com/app/. On the right, type what replaces it, for example http://localhost:3000/.
  4. Reload the page. The developer tools' Network panel shows the request going to the new address.
  5. When you are done, untick the row, switch the profile off, or press Alt+Shift+D to pause everything.

We checked this with HeaderDial 0.3.0 in Chrome 159.0.8154.6 and Firefox 158.0.1 in November 2026. A page on http://127.0.0.1:port loaded /prod.js?v=7, and with the rule in place the script that ran was http://localhost:port/dev.js?v=7: another origin, with the query kept. Page loads and fetch() calls were redirected too, and the profile's request headers were still sent to the new address. With the same rule but no site access granted, the original script loaded.

Replace or Regex

TypeLeftRightEffect
Replacehttps://cdn.example.com/app/http://localhost:3000/The first occurrence of the text is swapped; everything before and after it is kept.
Replace/api/v1//api/v2/Any host's v1 API calls go to v2 on the same host.
Regex^https://prod\.example\.com/(.*)https://staging.example.com/\1The whole URL must match; \1 to \9 insert the groups.

In our Chrome and Firefox runs, ^http://127\.0\.0\.1:(\d+)/api/v1/(.*)$ → http://localhost:\1/echo/v2/\2 took /api/v1/users?id=3 to /echo/v2/users?id=3 on the other host, port and query included.

Browsers compile these rules with their own regex engines, which accept a little less than JavaScript (Chrome documents its regexFilter as RE2 syntax, which has no lookaheads or back-references). If the browser rejects a pattern, HeaderDial lists it under the editor and keeps every other rule running.

Things that stop a redirect working

Coming from ModHeader?

ModHeader profile exports keep URL replacements as pairs of text (urlReplacements). When you import a ModHeader export, each pair becomes a Replace redirect in the same profile, so check them once after importing.