Dont use the service worker cache as it interferes with the content security policy

If we use this, then the CSP can't set security policies as
granularly, as almost everything will go through connect-src,
like every time we get a fallback image it would go through
fetch and connect-src would have to allow all https.
This commit is contained in:
Jackson Harper 2023-09-28 15:11:17 +08:00
parent c9b178ca5c
commit d120a6aa3d

View file

@ -129,23 +129,6 @@
})
}
function handleFetchRequest(ev) {
const request = ev.request
if (request.method === 'POST') {
const requestUrl = new URL(request.url)
if (requestUrl.pathname === '/share-target') {
const shareRequest = handleShareTarget(request)
return shareRequest
}
}
if (naviApi.onLine) {
return globalApi.fetch(request)
}
return fetchWithCacheBackup(request)
}
function handleOutdatedCache() {
return globalApi.caches.keys().then((cacheNames) => {
return Promise.all(
@ -181,8 +164,16 @@
if (ev.request.destination === 'script') {
return
}
if (ev.request.destination === 'image') {
return
}
const handler = handleFetchRequest(ev)
ev.respondWith(handler)
if (ev.request.method === 'POST') {
const requestUrl = new URL(request.url)
if (requestUrl.pathname === '/share-target') {
const shareRequest = handleShareTarget(request)
return shareRequest
}
}
})
})()