mirror of
https://github.com/bretzel-app/crumbs.git
synced 2026-10-12 20:06:57 +02:00
fix: restrict SW API caching to GET requests to avoid intercepting mutations
Workbox route matching intercepts all HTTP methods, which caused PUT/POST requests (e.g. preferences updates) to be handled by the SW strategy handler instead of passing through directly. Restrict API and attachment cache rules to GET-only using function-based urlPattern. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
202065380a
commit
4b233ba360
+5
-2
@@ -52,7 +52,9 @@ export default defineConfig({
|
||||
}
|
||||
},
|
||||
{
|
||||
urlPattern: /\/api\/notes\/.*\/attachments\?attachmentId=/,
|
||||
urlPattern: ({ request, url }) =>
|
||||
request.method === 'GET' &&
|
||||
/\/api\/notes\/.*\/attachments\?attachmentId=/.test(url.href),
|
||||
handler: 'CacheFirst',
|
||||
options: {
|
||||
cacheName: 'attachment-cache',
|
||||
@@ -60,7 +62,8 @@ export default defineConfig({
|
||||
}
|
||||
},
|
||||
{
|
||||
urlPattern: /^https?:\/\/.*\/api\//,
|
||||
urlPattern: ({ request, url }) =>
|
||||
request.method === 'GET' && /\/api\//.test(url.pathname),
|
||||
handler: 'NetworkFirst',
|
||||
options: {
|
||||
cacheName: 'api-cache',
|
||||
|
||||
Reference in New Issue
Block a user