0

Trying to read a file from a server on my background.js inside a chrome extension and having lots of trouble. Sorry if I post it the wrong way I'm new to the community lol my background.js

var x = getAuth();
function getAuth(){
const url = chrome.runtime.getURL('https://blablabla.com/content/uploads/asd/01/users.txt');

fetch(url)
    .then(() => console.log(response))   
}

my manfest

"permissions": [
    "https://blablabla.com/content/uploads/asd/01/users.txt"
    ],    

"background":{"scripts":["js/background.js"]},
"web_accessible_resources": [
    "https://blablabla.com/content/uploads/asd/01/users.txt"
],

this is what I get:

Failed to load resource: net::ERR_FILE_NOT_FOUND Uncaught (in promise) TypeError: Failed to fetch

Am I missing something?Thx for your help guys

  • Remove `web_accessible_resources` section and remove chrome.runtime.getURL call. Also use [devtools debugger for the background script](https://stackoverflow.com/a/10258029) to step through your code and inspect the variables so you will instantly see what's wrong. – wOxxOm Jan 08 '21 at 20:57
  • hey man thx! that did the job! Now just need to understand how to close the questions lol and flag you as correct lol – Alexandre Leitão Jan 08 '21 at 21:27

0 Answers0