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.
This commit is contained in:
1 parent
35e3de90b3
commit
063100fc5e
1 file changed
+7
-1
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user