diff --git a/sw.js b/sw.js index 7348a6d..f12bb86 100644 --- a/sw.js +++ b/sw.js @@ -1,4 +1,4 @@ -function registerWasmHTTPListener(wasm, { base, cacheName, args = [] } = {}) { +function registerWasmHTTPListener(wasm, { base, cacheName, passthroughFunc, args = [] } = {}) { let path = new URL(registration.scope).pathname if (base && base !== '') path = `${trimEnd(path, '/')}/${trimStart(base, '/')}` @@ -17,6 +17,10 @@ function registerWasmHTTPListener(wasm, { base, cacheName, args = [] } = {}) { WebAssembly.instantiateStreaming(source, go.importObject).then(({ instance }) => go.run(instance)) addEventListener('fetch', e => { + if (passthroughFunc && passthroughFunc(e.request)) { + e.respondWith(fetch(e.request)) + return; + } const { pathname } = new URL(e.request.url) if (!pathname.startsWith(path)) return