aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorKostiantyn Miakshyn <molodchick@gmail.com>2024-12-06 17:28:42 +0100
committerKostiantyn Miakshyn <molodchick@gmail.com>2024-12-06 17:33:26 +0100
commit2e1cd23a7da2f911d29bb0da910cbbd62168f92e (patch)
tree11aa9827aeb3fa734f4510196814c8b5de6eabea /apps
parentad045d6ede511d15da045e64cc0ee988fd945a9f (diff)
downloadnextcloud-server-2e1cd23a7da2f911d29bb0da910cbbd62168f92e.tar.gz
nextcloud-server-2e1cd23a7da2f911d29bb0da910cbbd62168f92e.zip
fix: Fix ServiceWorker scope when Nextcloud installed in subfolder
Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/files/src/services/ServiceWorker.js5
1 files changed, 3 insertions, 2 deletions
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 })