fix: #9127, scope service worker to relative_path for the forum (#9239)

Adds a `Service-Worker-Allowed` header on `assets/src/service-worker.js` URL and uses `scope` option during registration to ensure the service worker is correctly scoped to the entire forum and only the forum.
This commit is contained in:
Opliko
2021-02-02 01:40:14 +01:00
committed by GitHub
parent 897d29ecd6
commit 2bc74cffe6
2 changed files with 4 additions and 3 deletions

View File

@@ -788,7 +788,7 @@ app.cacheBuster = null;
function registerServiceWorker() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register(config.relative_path + '/assets/src/service-worker.js')
navigator.serviceWorker.register(config.relative_path + '/assets/src/service-worker.js', { scope: config.relative_path + '/' })
.then(function () {
console.info('ServiceWorker registration succeeded.');
}).catch(function (err) {