Better fix for system.custom_base_url, which does not affect other urls

This commit is contained in:
Matias Griese 2020-12-17 10:02:55 +02:00
parent e5727462e7
commit a24ec2c433

View File

@ -158,6 +158,11 @@ class Uri
/** @var Language $language */
$language = $grav['language'];
// add the port to the base for non-standard ports
if ($this->port !== null && $config->get('system.reverse_proxy_setup') === false) {
$this->base .= ':' . (string)$this->port;
}
// Handle custom base
$custom_base = rtrim($grav['config']->get('system.custom_base_url'), '/');
if ($custom_base) {
@ -170,6 +175,9 @@ class Uri
if (isset($custom_parts['scheme'])) {
$this->base = $custom_parts['scheme'] . '://' . $custom_parts['host'];
$this->port = $custom_parts['port'] ?? null;
if ($this->port !== null && $config->get('system.reverse_proxy_setup') === false) {
$this->base .= ':' . (string)$this->port;
}
$this->root = $custom_base;
} else {
$this->root = $this->base . $this->root_path;
@ -179,11 +187,6 @@ class Uri
$this->root = $this->base . $this->root_path;
}
// add the port to the base for non-standard ports
if ($this->port !== null && $config->get('system.reverse_proxy_setup') === false) {
$this->base .= ':' . (string)$this->port;
}
$this->url = $this->base . $this->uri;
$uri = Utils::replaceFirstOccurrence(static::filterPath($this->root), '', $this->url);