Merge pull request #49694 from nextcloud/bugfix/fix-service-worker-scope

This commit is contained in:
John Molakvoæ 2024-12-11 10:26:16 +01:00 committed by GitHub
commit 94fa2cf79f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 5 deletions

View file

@ -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 })

4
dist/files-init.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long