Skip to content

Commit 52d8403

Browse files
authored
🤖 Fix service worker cache errors for POST requests (#446)
Service worker was attempting to cache all requests including POST requests (from browser mode IPC calls and AI streaming). The Cache API only supports caching GET requests. Added check to skip caching for non-GET requests, preventing the error: `Failed to execute 'put' on 'Cache': Request method 'POST' is unsupported` This fix maintains PWA caching for browser mode while avoiding errors during development and when using POST-based features. _Generated with `cmux`_
1 parent 9eb6db0 commit 52d8403

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

public/service-worker.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ self.addEventListener('activate', (event) => {
3333

3434
// Fetch event - network first, fallback to cache
3535
self.addEventListener('fetch', (event) => {
36+
// Skip caching for non-GET requests (POST, PUT, DELETE, etc.)
37+
// The Cache API only supports GET requests
38+
if (event.request.method !== 'GET') {
39+
event.respondWith(fetch(event.request));
40+
return;
41+
}
42+
3643
event.respondWith(
3744
fetch(event.request)
3845
.then((response) => {

0 commit comments

Comments
 (0)