diff --git a/src/shinylive-sw.ts b/src/shinylive-sw.ts index 1b5666f5..c4c1d71f 100644 --- a/src/shinylive-sw.ts +++ b/src/shinylive-sw.ts @@ -186,16 +186,14 @@ self.addEventListener("fetch", function (event): void { return; } - event.respondWith( - (async (): Promise => { - const resp = await fetch(request); - if (coiRequested) { + if (coiRequested) { + event.respondWith( + (async (): Promise => { + const resp = await fetch(request); return addCoiHeaders(resp); - } else { - return resp; - } - })(), - ); + })(), + ); + } }); // =============================================================================