Skip to content

Commit

Permalink
fix(settings): Allow to connect to local address when checking for `.…
Browse files Browse the repository at this point in the history
…mjs` support

Also reduce the severity in case of a failed check to warning.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Jan 21, 2024
1 parent 1612d02 commit 1fcde52
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apps/settings/lib/SetupChecks/JavaScriptModules.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,18 @@ public function run(): SetupResult {
foreach ($testURLs as $testURL) {
try {
$client = $this->clientService->newClient();
$response = $client->head($testURL, ['connect_timeout' => 10]);
$response = $client->head($testURL, [
'connect_timeout' => 10,
'nextcloud' => [
'allow_local_address' => true,
],
]);
if (preg_match('/(text|application)\/javascript/i', $response->getHeader('Content-Type'))) {
return SetupResult::success();
}
} catch (\Throwable $e) {
$this->logger->debug('Can not connect to local server for checking JavaScript modules support', ['exception' => $e, 'url' => $testURL]);
return SetupResult::warning($this->l10n->t('Could not check for JavaScript support. Please check manually if your webserver serves `.mjs` files using the JavaScript MIME type.'));
}
}
return SetupResult::error($this->l10n->t('Your webserver does not serve `.mjs` files using the JavaScript MIME type. This will break some apps by preventing browsers from executing the JavaScript files. You should configure your webserver to serve `.mjs` files with either the `text/javascript` or `application/javascript` MIME type.'));
Expand Down

0 comments on commit 1fcde52

Please sign in to comment.