diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index fd0f3bdf26166..c5ac4b9afc89f 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -400,6 +400,7 @@ public function getNodeType($folderpath) { /** * @NoAdminRequired * @NoCSRFRequired + * @PublicPage */ public function serviceWorker(): StreamResponse { $response = new StreamResponse(__DIR__ . '/../../../../dist/preview-service-worker.js'); diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index d06ea49ed1748..e26d6bced6537 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -320,6 +320,8 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal ); $policy = new ContentSecurityPolicy(); $policy->addAllowedFrameDomain('\'self\''); + // Allow preview service worker + $policy->addAllowedWorkerSrcDomain('\'self\''); $response->setContentSecurityPolicy($policy); $this->provideInitialState($dir, $openfile); diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php index 64f0f10671c21..43a999bc5af93 100644 --- a/apps/files/tests/Controller/ViewControllerTest.php +++ b/apps/files/tests/Controller/ViewControllerTest.php @@ -402,6 +402,7 @@ public function testIndexWithRegularBrowser() { ); $policy = new Http\ContentSecurityPolicy(); $policy->addAllowedFrameDomain('\'self\''); + $policy->addAllowedWorkerSrcDomain('\'self\''); $expected->setContentSecurityPolicy($policy); $this->activityHelper->method('getFavoriteFilePaths')