Skip to content

Commit

Permalink
Enable HMR depending on debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Heinrich committed Feb 22, 2024
1 parent 9c00d12 commit 3dfb4ac
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/private/AppFramework/Middleware/Security/CSPMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ public function afterController($controller, $methodName, Response $response): R
$defaultPolicy->useJsNonce($this->csrfTokenManager->getToken()->getEncryptedValue());
}

// Loosen security presets in debug mode to enable development
// tools functionality
$debugging = \OC::$server->getConfig()->getSystemValue('debug', false);
if ($debugging) {
// Allow vue dev tool to work on Firefox.
$defaultPolicy->allowEvalScript(true);
// Unblock HMR requests.
$defaultPolicy->addAllowedConnectDomain('*');
$defaultPolicy->addAllowedScriptDomain('*');
}

$response->setContentSecurityPolicy($defaultPolicy);

return $response;
Expand Down

0 comments on commit 3dfb4ac

Please sign in to comment.