diff --git a/lib/Service/FileService.php b/lib/Service/FileService.php index 7b8860c8b4..1b5fefa7fa 100644 --- a/lib/Service/FileService.php +++ b/lib/Service/FileService.php @@ -13,6 +13,7 @@ use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; +use OCP\IConfig; use OCP\IRequest; use OCP\IURLGenerator; use OCP\IUserSession; @@ -40,6 +41,7 @@ public function __construct( private readonly IRootFolder $rootFolder, private readonly IManager $shareManager, private readonly IURLGenerator $urlGenerator, + private readonly IConfig $config, ) {} /** @@ -88,7 +90,14 @@ public function getShareLink(IShare $share): string */ private function getCurrentDomain(): string { - return $this->urlGenerator->getBaseUrl(); + $baseUrl = $this->urlGenerator->getBaseUrl(); + $trustedDomains = $this->config->getSystemValue('trusted_domains'); + + if(isset($trustedDomains[1]) === true) { + $baseUrl = str_replace(search: 'localhost', replace: $trustedDomains[1], subject: $baseUrl); + } + + return $baseUrl; } /**