other: disable service worker in debug mode

Signed-off-by: Varun Patil <radialapps@gmail.com>
pulsejet/aio-hw-docs
Varun Patil 2023-11-14 01:10:29 -08:00
parent 623cbe5d79
commit 7eb232c10f
1 changed files with 5 additions and 0 deletions

View File

@ -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' => '/',