fix: Convert http to ws scheme in node_console WebSocket URL

This commit is contained in:
YueGuobin 2026-06-14 21:57:58 +08:00
parent 80d5ae91a4
commit e17d298bc7
No known key found for this signature in database

View File

@ -281,9 +281,11 @@ def get_node_console_info_handler(params: dict[str, Any], gns3_ctx: dict[str, An
# Short-lived JWT for the WebSocket URL (10 min)
username = gns3_ctx.get("jwt_username")
ws_token = auth_service.create_access_token(username, expires_in=10) if username else None
ws_url = f"{gns3_ctx['server_url']}/v3/projects/{project_id}/nodes/{node_id}/console/ws"
raw_url = f"{gns3_ctx['server_url']}/v3/projects/{project_id}/nodes/{node_id}/console/ws"
if ws_token:
ws_url += f"?token={ws_token}"
raw_url += f"?token={ws_token}"
# Convert http scheme to ws for direct websocat usage
ws_url = raw_url.replace("https://", "wss://").replace("http://", "ws://")
result = {
"node_id": node_id,