BUG Prioritise SS_BASE_URL over flakey SCRIPT_FILENAME check

This commit is contained in:
Damian Mooyman 2017-08-24 12:58:04 +12:00
parent 47fced8880
commit 80cf096a6e
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A
1 changed files with 7 additions and 7 deletions

View File

@ -75,6 +75,13 @@ if (!getenv('SS_IGNORE_DOT_ENV')) {
if (!defined('BASE_URL')) {
define('BASE_URL', call_user_func(function () {
// Prefer explicitly provided SS_BASE_URL
$base = getenv('SS_BASE_URL');
if ($base) {
// Strip relative path from SS_BASE_URL
return rtrim(parse_url($base, PHP_URL_PATH), '/');
}
// Determine the base URL by comparing SCRIPT_NAME to SCRIPT_FILENAME and getting common elements
// This tends not to work on CLI
$path = realpath($_SERVER['SCRIPT_FILENAME']);
@ -87,13 +94,6 @@ if (!defined('BASE_URL')) {
}
}
// Fall back to SS_BASE_URL
$base = getenv('SS_BASE_URL');
if ($base) {
// Strip relative path from SS_BASE_URL
return rtrim(parse_url($base, PHP_URL_PATH), '/');
}
// Assume no base_url
return '';
}));