scratchfoundation / scratch-storage

Load and store project and asset files for Scratch 3.0
BSD 3-Clause "New" or "Revised" License
58 stars 132 forks source link

Static assets give 404 errors (but still load) #27

Closed ericrosenbaum closed 6 years ago

ericrosenbaum commented 6 years ago

Expected Behavior

Loading static assets should leave the console quiet.

Actual Behavior

When you load a static asset, for example https://llk.github.io/scratch-gui/develop/static/extension-assets/scratch3_music/instruments/1-piano/36.mp3, it works, but you also get a 404 error because storage first looks for it on the assets server:

Failed to load https://cdn.assets.scratch.mit.edu/internalapi/asset/instruments/1-piano/36.mp3/get/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://llk.github.io' is therefore not allowed access. The response had HTTP status code 404.

Steps to Reproduce

Load the music extension and check the console.

pyz1989 commented 6 years ago

// WebHelper.js

nets({ url: url }, function (err, resp, body) {
    // body is a Buffer
    if (err) {
        tryNextSource();
    } else {
        asset.setData(body, dataFormat);
        fulfill(asset);
    }
});

To load the MP3 from CDN, Maybe the network, I got this result Error_scratch-storage-404

Because err is null, tryNextSource does not work. I can not load the mp3 from local Load fail, the misic blocks did not work.