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
- 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.
- Click + URL redirect. Keep the type on Replace.
- 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 examplehttp://localhost:3000/. - Reload the page. The developer tools' Network panel shows the request going to the new address.
- 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
| Type | Left | Right | Effect |
|---|---|---|---|
| Replace | https://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/\1 | The 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
- A loop. If the target contains the text it replaces (
/v1/→/v1/beta/), every redirected request would match again. HeaderDial marks the row red and does not apply it. - Site access. The extension needs access to the site the request is going to. Chrome's declarativeNetRequest documentation says it also needs access to the page that makes the request; Allow on all sites covers both.
- CORS. A
fetch()redirected to another origin is a cross-origin request. Your dev server must answer withAccess-Control-Allow-Origin, or you can add that header as a response header in the same profile (see CORS headers for local development). Plain<script src>and<link rel="stylesheet">loads do not need it. - Subresource integrity. If the page's tag has an
integrity="sha256-…"attribute, the browser checks the file it receives against that hash, and a local build will not match. In our Chrome 159 run the same tag ran the original script, and after the redirect it ran nothing. Test on a page without the attribute. - Filters. "Never on" filters, the "Only in this tab" setting, request types and methods under Where it applies also limit redirects. "Only on" filters do not, because the left-hand text already says which URLs to redirect.
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.