From f02e0b5177b9bf979e4c3f97190e47effa005357 Mon Sep 17 00:00:00 2001 From: cj-vana Date: Mon, 22 Sep 2025 10:36:45 -0600 Subject: [PATCH] Update server.py --- agents/capture-agent-py/capture_agent/server.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/agents/capture-agent-py/capture_agent/server.py b/agents/capture-agent-py/capture_agent/server.py index 2ab2fa2..9938b75 100644 --- a/agents/capture-agent-py/capture_agent/server.py +++ b/agents/capture-agent-py/capture_agent/server.py @@ -322,11 +322,16 @@ async def handler(ws): # In websockets v15+, the ws object is a ServerConnection # Headers are accessed via ws.request.headers origin = ws.request.headers.get("Origin") if hasattr(ws, 'request') else None - if origin not in ALLOWED_ORIGINS: + + # Allow connections without Origin header (local/direct connections) + # or from allowed origins (browser connections) + if origin is None: + print("Client connected from local/direct connection (no Origin header)") + elif origin in ALLOWED_ORIGINS: + print(f"Client connected from allowed origin: {origin}") + else: print(f"Connection rejected from disallowed origin: {origin}") return - - print(f"Client connected from origin: {origin}") # Fix 4: Proper WebSocket client cleanup with try-finally blocks try: connected_clients.add(ws)