From ba0897a023c47d15ceb933d78e47d5afba96e282 Mon Sep 17 00:00:00 2001 From: jo Date: Tue, 22 Feb 2022 18:40:46 +0100 Subject: [PATCH] fix(shared): fix missing port in public_url --- shared/libretime_shared/config.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/shared/libretime_shared/config.py b/shared/libretime_shared/config.py index a7d27336e..5ce2edbf4 100644 --- a/shared/libretime_shared/config.py +++ b/shared/libretime_shared/config.py @@ -105,7 +105,7 @@ class GeneralConfig(BaseModel): protocol: str = "http" base_url: str = "localhost" - base_port: int = 80 + base_port: Optional[int] base_dir: str = "/" force_ssl: bool = False @@ -113,8 +113,13 @@ class GeneralConfig(BaseModel): def public_url(self) -> str: scheme = "https" if self.force_ssl else self.protocol - url = urlunsplit((scheme, self.base_url, self.base_dir, None, None)) - return url.rstrip("/") + location = self.base_url + if self.base_port is not None: + location += f":{self.base_port}" + + path = self.base_dir.rstrip("/") + + return urlunsplit((scheme, location, path, None, None)) # pylint: disable=too-few-public-methods