fix: add logic to automatically take over clients from old service workers

This commit is contained in:
Julian Lam
2024-09-12 11:21:55 -04:00
parent d4cf5e7ee0
commit 1fbf911489

View File

@@ -1,5 +1,15 @@
'use strict';
self.addEventListener('install', () => {
// Register self as the primary service worker
self.skipWaiting();
});
self.addEventListener('activate', (event) => {
// Take responsibility over existing clients from old service worker
event.waitUntil(self.clients.claim());
});
self.addEventListener('fetch', function (event) {
// This is the code that ignores post requests
// https://github.com/NodeBB/NodeBB/issues/9151