From 2e1cd23a7da2f911d29bb0da910cbbd62168f92e Mon Sep 17 00:00:00 2001 From: Kostiantyn Miakshyn Date: Fri, 6 Dec 2024 17:28:42 +0100 Subject: fix: Fix ServiceWorker scope when Nextcloud installed in subfolder Signed-off-by: Kostiantyn Miakshyn --- apps/files/src/services/ServiceWorker.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'apps') diff --git a/apps/files/src/services/ServiceWorker.js b/apps/files/src/services/ServiceWorker.js index 7d03af65e44..5f4c446f170 100644 --- a/apps/files/src/services/ServiceWorker.js +++ b/apps/files/src/services/ServiceWorker.js @@ -2,7 +2,7 @@ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ -import { generateUrl } from '@nextcloud/router' +import { generateUrl, getRootUrl } from '@nextcloud/router' import logger from '../logger.ts' export default () => { @@ -11,7 +11,8 @@ export default () => { window.addEventListener('load', async () => { try { const url = generateUrl('/apps/files/preview-service-worker.js', {}, { noRewrite: true }) - const registration = await navigator.serviceWorker.register(url, { scope: '/' }) + const scope = getRootUrl() + const registration = await navigator.serviceWorker.register(url, { scope }) logger.debug('SW registered: ', { registration }) } catch (error) { logger.error('SW registration failed: ', { error }) -- cgit v1.2.3