diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php index 4da6a91b6c..179efca0a2 100644 --- a/lib/private/URLGenerator.php +++ b/lib/private/URLGenerator.php @@ -59,6 +59,8 @@ class URLGenerator implements IURLGenerator { private $request; /** @var IRouter*/ private $router; + /** @var null|string */ + private $baseUrl = null; public function __construct(IConfig $config, ICacheFactory $cacheFactory, @@ -269,6 +271,9 @@ class URLGenerator implements IURLGenerator { * @return string base url of the current request */ public function getBaseUrl(): string { - return $this->request->getServerProtocol() . '://' . $this->request->getServerHost() . \OC::$WEBROOT; + if ($this->baseUrl === null) { + $this->baseUrl = $this->request->getServerProtocol() . '://' . $this->request->getServerHost() . \OC::$WEBROOT; + } + return $this->baseUrl; } }