mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUG Prioritise SS_BASE_URL over flakey SCRIPT_FILENAME check
This commit is contained in:
parent
47fced8880
commit
80cf096a6e
@ -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 '';
|
||||
}));
|
||||
|
Loading…
Reference in New Issue
Block a user