Skip to content

Commit f0a7c04

Browse files
committed
Adjusted trusted hosts env variable to let healt-checkfile be called on any env.
1 parent 8979bf6 commit f0a7c04

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

web/health-check.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
// Sending error code by default.
1616
http_response_code(500);
1717

18+
// Adjust trusted hosts settings to call health-check.php file from any host.
19+
putenv("DRUPAL_TRUSTED_HOST=" . $_SERVER['SERVER_NAME']);
20+
1821
try {
1922
// Loading standard Drupal Kernel process.
2023
$kernel = new DrupalKernel('prod', $autoloader);
@@ -31,14 +34,14 @@
3134
}
3235
else {
3336
$stderr = fopen('php://stderr', 'w');
34-
fwrite($stderr,print_r($_SERVER, 1) . "\n");
37+
fwrite($stderr,print_r($result, 1) . "\n");
3538
fwrite($stderr,print_r($response, 1) . "\n");
3639
fclose($stderr);
3740
}
3841
}
3942
catch (\Exception $exception) {
4043
$result = 'NOK' . PHP_EOL;
41-
$result = $exception->getMessage();
44+
$result .= $exception->getMessage();
4245
$fh = fopen('php://stderr','w');
4346
fwrite($fh, $result . "\n");
4447
fclose($fh);

0 commit comments

Comments
 (0)