Hello,
I try to modify the HTTP request headers with declarativeNetRequest.updateSessionRules()
, but it doesn’t work.
-
manifest.json
{ "manifest_version": 2, "name": "Test case", "version": "1.0.0", "background": { "page": "page.html", "persistent": true }, "permissions": [ "<all_urls>", "declarativeNetRequest" ] }
-
page.html
<!doctype html> <html> <head> <meta charset="utf-8" /> <title>Test case</title> </head> <body> <script src="script.js" type="module"></script> </body> </html>
-
script.js
await browser.declarativeNetRequest.updateSessionRules({ addRules: [ { action: { type: "modifyHeaders", requestHeaders: [ { header: "X-Foo", value: "bar", operation: "set", }, ], }, condition: { urlFilter: "httpbin", }, id: 1, }, ], });
When I go to https://httpbin.org/headers, I don’t see the X-Foo
header. Can you see why my extension does nothing?