From 6fa406f83faa890d82dabb5e2c5a87f553fa3807 Mon Sep 17 00:00:00 2001 From: Alejandro Cabeza Romero Date: Fri, 19 Dec 2025 13:04:33 +0100 Subject: [PATCH] Fix relative URL creation. --- src/node/api/http.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/node/api/http.py b/src/node/api/http.py index 10bf41c..cd55992 100644 --- a/src/node/api/http.py +++ b/src/node/api/http.py @@ -20,10 +20,11 @@ logger = logging.getLogger(__name__) class HttpNodeApi(NodeApi): - ENDPOINT_INFO = "/cryptarchia/info" - ENDPOINT_TRANSACTIONS = "/cryptarchia/transactions" - ENDPOINT_BLOCKS = "/cryptarchia/blocks" - ENDPOINT_BLOCKS_STREAM = "/cryptarchia/blocks/stream" + # Paths can't have a leading slash since they are relative to the base URL + ENDPOINT_INFO = "cryptarchia/info" + ENDPOINT_TRANSACTIONS = "cryptarchia/transactions" + ENDPOINT_BLOCKS = "cryptarchia/blocks" + ENDPOINT_BLOCKS_STREAM = "cryptarchia/blocks/stream" def __init__(self, settings: "NBESettings"): self.host: str = settings.node_api_host @@ -38,14 +39,16 @@ class HttpNodeApi(NodeApi): def base_url(self) -> str: if "/" in self.host: host, path = self.host.split("/", 1) - path = "/" + path + path = f"/{path}" + if not path.endswith("/"): + path += "/" else: host = self.host path = "" network_location = f"{host}:{self.port}" if self.port else host - return urlunparse( + url = urlunparse( ( self.protocol, network_location, @@ -56,6 +59,7 @@ class HttpNodeApi(NodeApi): "", # Fragment ) ) + return url async def get_health(self) -> HealthSerializer: url = urljoin(self.base_url, self.ENDPOINT_INFO)