Skip to content

Commit

Permalink
ISSUE-10615: Respect SS_BASE_URL scheme in CLI environment.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
s-kerdel authored Dec 13, 2022
1 parent 4e1b99b commit da18ce7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Control/CLIRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ public static function cleanEnvironment(array $variables)
$variables['_GET']['url'] = $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
return parent::cleanEnvironment($variables);
Expand Down

0 comments on commit da18ce7

Please sign in to comment.