MCT-master / mct-master.github.io

The blog of MCT
https://mct-master.github.io
14 stars 9 forks source link

Custom audio embedder does not load audio from other sites #41

Open aleksati opened 1 year ago

aleksati commented 1 year ago

I think this is not working properly, I think.

The custom audio embedder (https://github.com/MCT-master/mct-master.github.io#embedding-audio) only works for audio stored locally in the repository. Tested it with .wav audio loaded the from UiO blog repository for large files, but it did not fetch properly.

To edit the audio embedded, go to "utils/waveform.js"

aleksati commented 1 year ago

Apparently, it's a CORS issue as I get these error messages:

Acess to fetch at 'https://www.uio.no/english/studies/programmes/mct-master/blog/assets/audio/......wav' from origin 'http://127.0.0.1:4000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

aleksati commented 1 year ago

Adding a "no-cors" option to the WaveSurfer object fixed the CORS issue:

// utils/waveform.js - line 86
  let waveSurfer = WaveSurfer.create({
     ...,
    xhr: {
      mode: "no-cors",
    },
  });

However, another issue immerged. Now, it's just this:

Error: HTTP error status: 0 at fetch.js:210:19

When trying to load audio from a different server/site.