fix: pass gateway token via URL query parameter

Gateway may validate auth during HTTP upgrade before WebSocket
messages can be sent.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
operator
2026-04-19 05:44:11 +00:00
parent a6f63e15f4
commit fb53af642d

View File

@@ -212,7 +212,9 @@ export default {
reject(new Error('Gateway connection timeout'));
}, 15000);
const client = new (globalThis as any).WebSocket(gatewayUrl);
// Pass token via Authorization header in the upgrade request
const wsUrl = gwToken ? `${gatewayUrl}?token=${encodeURIComponent(gwToken)}` : gatewayUrl;
const client = new (globalThis as any).WebSocket(wsUrl);
client.onerror = (err: any) => {
clearTimeout(timeout);