From 063100fc5eac8367f874516e0aa3de999c8060ee Mon Sep 17 00:00:00 2001 From: TailScan Bot Date: Thu, 2 Apr 2026 07:37:59 +0000 Subject: [PATCH] fix: use request host for Guacamole client URL Instead of hardcoding GUAC_BASE in the browser-facing URL, derive the host from the incoming request headers. This makes the Guacamole link work correctly whether accessed via localhost, LAN IP, or a domain name. Internal server-side API calls to Guacamole still use GUAC_BASE. --- main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index aaa8cb2..3f8b9dc 100644 --- a/main.py +++ b/main.py @@ -615,7 +615,13 @@ async def api_guac_connect(request: Request, ip: str, port: int, proto: str): client_id = base64.b64encode( f"{conn_id}\0c\0postgresql".encode() ).decode().rstrip("=") - url = f"{GUAC_BASE}/#/client/{client_id}" + # Build the client URL using the incoming request's host so it + # works regardless of whether the user is on localhost, LAN IP, + # or a domain name. The internal GUAC_BASE is still used for + # server-side API calls; only the browser-facing URL changes. + request_host = request.headers.get("host", "localhost").split(":")[0] + guac_public_base = f"http://{request_host}:8085/guacamole" + url = f"{guac_public_base}/#/client/{client_id}" return {"url": url, "connection_id": conn_id} except httpx.HTTPStatusError as e: