From 7eb232c10f616fb70e54b8ac04c5e40295268b65 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Tue, 14 Nov 2023 01:10:29 -0800 Subject: [PATCH] other: disable service worker in debug mode Signed-off-by: Varun Patil --- lib/Controller/OtherController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Controller/OtherController.php b/lib/Controller/OtherController.php index 8e7d40d4..b1a04bc9 100644 --- a/lib/Controller/OtherController.php +++ b/lib/Controller/OtherController.php @@ -166,6 +166,11 @@ class OtherController extends GenericApiController return Util::guardEx(static function () use ($name) { switch ($name) { case 'service-worker.js': + // Disable service worker if server is in debug mode + if (\OC::$server->get(\OCP\IConfig::class)->getSystemValue('debug', false)) { + throw Exceptions::NotFound('Service worker is disabled in debug mode'); + } + $response = (new StreamResponse(__DIR__.'/../../js/memories-service-worker.js'))->setHeaders([ 'Content-Type' => 'application/javascript', 'Service-Worker-Allowed' => '/',