From a24ec2c433e9eb5ff386361df3dc868ccdbfd0f0 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Thu, 17 Dec 2020 10:02:55 +0200 Subject: [PATCH] Better fix for `system.custom_base_url`, which does not affect other urls --- system/src/Grav/Common/Uri.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/system/src/Grav/Common/Uri.php b/system/src/Grav/Common/Uri.php index 071ce4424..ec842b504 100644 --- a/system/src/Grav/Common/Uri.php +++ b/system/src/Grav/Common/Uri.php @@ -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);