Trying to load an mp3 file from the following source: https://static.twilio.com/libs/twiliojs/refs/82278dd/sounds/dtmf-1.mp3
Using very simple request redirecting code in service worker:
function onFetch(event) {
if (event.request.url.indexOf('.mp3') >= 0) {
event.respondWith(fetch(event.request.url, {mode: 'no-cors'}));
} else {
event.respondWith(fetch(event.request));
}
}
have tried other options as well:
fetch(event.request)
fetch(event.request.url)
fetch(event.request.url, {mode: 'cors'})
note: no error thrown in service worker if I pass {mode: 'no-cors'}, error thrown for all other mentioned cases:
Fetch API cannot load https://static.twilio.com/libs/twiliojs/refs/82278dd/sounds/dtmf-1.mp3. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'my origin' is therefore not allowed access.
I think the issue may be is that Service Worker does not send Accept-Encoding and Range Headers, so it does not load the resource.
Any kind of help, hacking would be appreciated.