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);