Fix managed mode WebSocket URL when server_url uses https://
All checks were successful
Tests / Python Backend Tests (push) Successful in 5s
Tests / Frontend Tests (push) Successful in 7s
Tests / Rust Sidecar Tests (push) Successful in 2m21s

The URL builder was prepending wss:// to the full https:// URL, producing
an invalid wss://https://... URL. Now properly converts https→wss and
http→ws before appending the /ws/transcribe path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Developer
2026-04-10 20:03:50 -07:00
parent f7b9695418
commit ef188e1f67

View File

@@ -320,9 +320,13 @@ class DeepgramTranscriptionEngine:
def _build_ws_url_and_headers(self): def _build_ws_url_and_headers(self):
"""Return ``(url, headers)`` depending on the current mode.""" """Return ``(url, headers)`` depending on the current mode."""
if self.mode == "managed": if self.mode == "managed":
# Ensure the server URL uses wss:// and append the path # Convert HTTP(S) URLs to WS(S) for WebSocket connection
url = self.server_url.rstrip("/") url = self.server_url.rstrip("/")
if not url.startswith("ws://") and not url.startswith("wss://"): if url.startswith("https://"):
url = "wss://" + url[len("https://"):]
elif url.startswith("http://"):
url = "ws://" + url[len("http://"):]
elif not url.startswith("ws://") and not url.startswith("wss://"):
url = f"wss://{url}" url = f"wss://{url}"
url = f"{url}/ws/transcribe" url = f"{url}/ws/transcribe"
return url, {} return url, {}