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

Viewed 1007

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 relevant 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 relevant 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.

1 Answers

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

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