0

I have a tiny HTML/CSS/JS app I use to read and play certain types of files. I have no need for it to be on a server.

As of yesterday, it "worked." Suddenly, today I'm getting an error about using fetch with local files. I did make some settings changes on my Windows 10 laptop.

abcjs-init.js:15 Fetch API cannot load file:///E:/OneDrive/Documents/ABCJS-Minimal-Editor-Notation-Player/tunes/tune_list.txt. URL scheme "file" is not supported.

This is my code:

fetch(tunes_list_path,  {mode: 'no-cors'})
    .then(response =>
    {
        console.log("response:", response);
        return response
    })
    .then(data => 
    {
        console.log("data:", data)
        return data.text()
    })
    .then(Normal =>
    {
        console.log("got tunelist");
        console.log("tune_list");
        
        let  tune_list = Normal.split("\n").sort();
        addTunesToSelector(tune_list);
    })
    .catch(err =>
    {
        console.log('Fetch problem show: ' + err.message);
    });

Further up is: let tunes_list_path = "tunes/tune_list.txt";.

The index.html loads fine. I can also view the file in the error directly with its URL. So it is visible to the browser.

Do I need to enable something in my browser? Add something to the fetch call?

abalter
  • 9,663
  • 17
  • 90
  • 145

1 Answers1

0

Aha! I had changed a setting in Firefox that allowed COORS with local files: privacy.file_unique_origin.

I apparently erased that setting during my OS maintenance.

This solution is only for FF. There may be an equivalent setting for Chromium-based browsers.

abalter
  • 9,663
  • 17
  • 90
  • 145