Search code examples
javascriptfirefoxfetchfirefox-addon

Firefox: "TypeError: NetworkError when attempting to fetch resource." when accessing raw.githubusercontent.com data from extension


While developing an add-on for Firefox I stumbled upon this error:

"TypeError: NetworkError when attempting to fetch resource."

I have this exact same code for Google Chrome and it works fine. There are many other threads on Stackoverflow that covered this same error, but none of the solutions helped me. Enabling CORS through https://addons.mozilla.org/en-US/firefox/addon/cors-everywhere/ didn't do the trick either.

My related manifest.js:

"matches": [
          "https://letterboxd.com/film/*",
          "http://letterboxd.com/film/*"
      ],

I have tried to include all urls or my specific github json file into the manifest but it didn't help.

My related content.js:

fetch('https://raw.githubusercontent.com/*USER*/*PATH*/main/*FILE*.json')
    .then(res => res.json())
    .then((out) => {
        out.find(function(item, i){
          /***/
        });
});

I'd be forever grateful for any help I can get.


Solution

  • You have to specify permissions inside your manifest.json file.

    "permissions": [ "*://example.com/*" ]