fix: update service worker to return error response when proxy is undefined
Previously, when _portal_proxy was not defined, the service worker would proceed with fetching the request, potentially leading to silent failures. Now, it responds with a 500 status and a user-friendly message instructing to refresh the page, improving error handling and user experience.
lemon-mint committed
Oct 31, 2025 at 12:52 UTC
e125f9d27e81bc7300192b0901bb7db3c3875f5a
1 file changed
+1
-1
cmd/webclient/service-worker.js
+1
-1
@@ -81,7 +81,7 @@ async function proxy_handler(event) {
81
}
82
83
console.log('Service Worker: _portal_proxy is not defined. Fetch event ignored.');
84
- event.respondWith(fetch(event.request));
84
+ event.respondWith(new Response('Service Worker: Failed to process request, please refresh the page.', { status: 500 }));
85
}
86
87
self.addEventListener('fetch', proxy_handler);