Cannot fetch http only url in manifest v3 extension

In manifest v3 extension, any http only url cannot be fetched.

manifest.json

{
    "manifest_version": 3,
    "version": "0.0.0",
    "name": "test",
    "background":{
        "scripts": ["background.js"]
    },
    "host_permissions": ["<all_urls>"]
}

background.js

const init = () => {
  fetch("http://http.rip")
    .then((res) => res.text())
    .then((text) => {
      console.log(text);
    })
    .catch((err) => {
      console.error(err);
    });
};

browser.runtime.onStartup.addListener(init);

browser.runtime.onInstalled.addListener(init);

How do I fetch http only url in Firefox manifest v3?

You can fetch http only url in Chrome.

Add this CSP to manifest.json:

"content_security_policy": {
    "extension_pages": "script-src 'self';"
}

References:
Upgrade insecure network requests in Manifest V3
Default content security policy

2 Likes

That worked. Thanks!