# onBeforeRequest Blocking & Redirecting

**URL:** <https://discourse.mozilla.org/t/onbeforerequest-blocking-redirecting/141848>\
**Category:** Development\
**Tags:** issue\
**Created:** [March 25, 2025, 11:25pm UTC](https://discourse.mozilla.org/t/onbeforerequest-blocking-redirecting/141848 "2025-03-25T23:25:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![viyok](https://avatars.discourse-cdn.com/v4/letter/v/ce73a5/32.png) [@viyok](https://discourse.mozilla.org/u/viyok)\
**Post date:** [March 25, 2025, 11:25pm UTC](https://discourse.mozilla.org/t/onbeforerequest-blocking-redirecting/141848/1 "2025-03-25T23:25:30Z")

</div>

Hi. I’m trying to use onBeforeRequest to block an incoming request, and when debugging it works (sometimes).

This is the manifest file

```json
{
  "manifest_version": 2,
  "name": "WBlist",
  "version": "0.1",

  "permissions": [
    "webRequest",
    "webRequestBlocking",
    "tabs",
    "webNavigation",
    "browsingData",
    "browserSettings"
  ],

  "background": { "scripts": ["wblist.js"] }
}

```

And this the wblist.js

```auto
console.log("Add-on loaded");

browser.webRequest.onBeforeRequest.addListener((details) => {
    console.log(details);
    return { cancel: true };
}, { urls: ["<all_urls>"] }, ["blocking"]);

```

Idk what I do that it works for a few minutes and then I reload or load the addon in the debugger it doesn’t work anymore.

I’m also trying to use redirectUrl, but the changes to the manifest also screw up the functioning of the script. Plz help.
