I'm trying to use a service worker to add some additional headers to image and video requests but on Firefox the fetch event is only being invoked for the images and not … (xem thêm)
I'm trying to use a service worker to add some additional headers to image and video requests but on Firefox the fetch event is only being invoked for the images and not the videos. On Chrome it is called for both.
I cannot find any documentation that says Firefox does not support service workers for video but this appears to be the case. Can anybody point me in the right direction?
sw.js
'use strict';
self.addEventListener("install", (event) => {
// Force the newly installed service worker to replace any earlier version
self.skipWaiting();
});
self.addEventListener("activate", (event) => {
// Activate the service worker immediately in all clients
event.waitUntil(self.clients.claim());
});
self.addEventListener('fetch', (event) => {
console.log(`SW.js: ${event.request.url}`);
const updatedHeaders = new Headers(event.request.headers);
//updatedHeaders.set('Accept', '*');
// Create a new request object with the updated headers
const updatedRequest = new Request(event.request, {
headers: updatedHeaders
});
event.respondWith(fetch(updatedRequest));
});