From 0b429792ec07cc185fd7ea72c46c5fcbd667dc8d Mon Sep 17 00:00:00 2001 From: Ammar Date: Mon, 27 Oct 2025 02:58:47 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Fix=20service=20worker=20cache?= =?UTF-8?q?=20errors=20for=20POST=20requests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- public/service-worker.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/public/service-worker.js b/public/service-worker.js index 4ac48d421..e88aae780 100644 --- a/public/service-worker.js +++ b/public/service-worker.js @@ -33,6 +33,13 @@ self.addEventListener('activate', (event) => { // Fetch event - network first, fallback to cache self.addEventListener('fetch', (event) => { + // Skip caching for non-GET requests (POST, PUT, DELETE, etc.) + // The Cache API only supports GET requests + if (event.request.method !== 'GET') { + event.respondWith(fetch(event.request)); + return; + } + event.respondWith( fetch(event.request) .then((response) => {