fix updated broker key needed#72
Conversation
There was a problem hiding this comment.
🔴 Broker API key not passed to the hybrid WebSocket connection to the broker
The PR adds brokerApiKey authentication to all HTTP requests to the broker (send, spawned, proxy routes), but the handleHybridWebSocket function in packages/dashboard-server/src/websocket/standalone.ts:144 creates a new WebSocket(brokerWsUrl) connection to the broker without including the x-api-key header. When RELAY_BROKER_API_KEY is configured, the broker presumably requires it on all endpoints. The WebSocket connection will fail to authenticate, triggering the fallback to snapshot polling and losing real-time broker event streaming.
Affected call site and WebSocket creation
The call at packages/dashboard-server/src/proxy-server.ts:521 passes only (ws, getRelaycastSnapshot, relayUrl, verbose) — brokerApiKey is never provided. Inside handleHybridWebSocket at packages/dashboard-server/src/websocket/standalone.ts:144, the WebSocket is created with no headers:
const bws = new WebSocket(brokerWsUrl);The Node.js ws library supports passing headers via new WebSocket(url, { headers: { 'x-api-key': key } }), so this should be straightforward to fix.
(Refers to line 521)
Prompt for agents
The handleHybridWebSocket function in packages/dashboard-server/src/websocket/standalone.ts needs to accept an optional brokerApiKey parameter and pass it as an x-api-key header when creating the broker WebSocket connection at line 144. The call site in packages/dashboard-server/src/proxy-server.ts:521 needs to pass the brokerApiKey value.
1. Update handleHybridWebSocket signature to add brokerApiKey?: string parameter
2. At line 144 in standalone.ts, change: const bws = new WebSocket(brokerWsUrl); to: const bws = new WebSocket(brokerWsUrl, brokerApiKey ? { headers: { 'x-api-key': brokerApiKey } } : undefined);
3. Update the call at proxy-server.ts:521 to pass brokerApiKey: handleHybridWebSocket(ws, getRelaycastSnapshot, relayUrl, verbose, brokerApiKey)
Was this helpful? React with 👍 or 👎 to provide feedback.
Uh oh!
There was an error while loading. Please reload this page.