I built FocusBlock, a local-first website blocker for Edge, using declarativeNetRequest. During real-browser testing I hit a failure mode that cost me an hour. The docs explain it — once you know where to look.
The symptom
- The rules registered fine.
getDynamicRules()showed them. - The
blockaction worked: the request was stopped. - The
redirectaction did nothing. No error, no console warning. The request simply was not redirected, and the tab loaded normally.
A minimal repro confirmed it: a fresh extension with a single redirect rule (a urlFilter for example.com, redirecting to an extension page) behaved the same way — block works, redirect silently skipped.
What the docs say
The declarativeNetRequest permission by itself only covers allow/block-style actions. A redirect action requires the extension to hold host permission for the request URL. Chrome's documentation states this in the Permissions section and again under Redirects.
So a redirect rule can register successfully and then be silently skipped at runtime when the host permission is missing. No error is surfaced anywhere.
The fix
Add host permissions to the manifest:
"host_permissions": ["<all_urls>"]
And make the redirect target reachable via web_accessible_resources:
"web_accessible_resources": [
{ "resources": ["src/blocked/*"], "matches": ["<all_urls>"] }
]
After that, the same rules redirected correctly — example.com loaded the local block page, with the blocked host shown on it.
Takeaway
If your declarativeNetRequest redirect rule registers but never fires, check host permissions first. The rule showing up in getDynamicRules() proves it was accepted, not that it can run.
FocusBlock is live on Edge Add-ons: https://microsoftedge.microsoft.com/addons/detail/focusblock/kdpeddhiegpfadpjiaieoaeiloebgdhp — free, local-first, no account, no tracking. Privacy policy: https://alapha888.github.io/focus-block-privacy/
Top comments (0)