ISSUE-10615: Respect SS_BASE_URL scheme in CLI environment.

Additionally set _SERVER variables for HTTPS and SSL to respect SS_BASE_URL scheme when executing builds and tasks through CLI.
This should solve base tags not being provided with the correct HTTP scheme. This is important to resolve mixed content issues and insecure requests.
This commit is contained in:
Shiva Kerdel 2022-12-13 16:51:04 +01:00 committed by Guy Sartorelli
parent ce53318d26
commit 4a1eb0c158
No known key found for this signature in database
GPG Key ID: F313E3B9504D496A

View File

@ -65,6 +65,13 @@ class CLIRequestBuilder extends HTTPRequestBuilder
$variables['_SERVER']['REQUEST_URI'] = $variables['_SERVER']['argv'][1]; $variables['_SERVER']['REQUEST_URI'] = $variables['_SERVER']['argv'][1];
} }
// Set 'HTTPS' and 'SSL' flag for CLI depending on SS_BASE_URL scheme value.
$scheme = parse_url(Environment::getEnv('SS_BASE_URL') ?? '', PHP_URL_SCHEME);
if ($scheme == 'https') {
$variables['_SERVER']['HTTPS'] = 'on';
$variables['_SERVER']['SSL'] = true;
}
// Parse rest of variables as standard // Parse rest of variables as standard
return parent::cleanEnvironment($variables); return parent::cleanEnvironment($variables);
} }