From 868bef0c5673c871d80b360aa159ca017d1c1ab6 Mon Sep 17 00:00:00 2001 From: "soroush.asadi" Date: Mon, 15 Jun 2026 18:07:58 +0330 Subject: [PATCH] revert(signalr): restore negotiate + auto-transport (CDN now bypassed) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit api.bargevasat.ir is now CDN-bypassed (origin answers directly), so the negotiate POST works again. Drop the WS-only skipNegotiation workaround and use the standard negotiate flow, which auto-falls back WS → SSE → long-poll if a WebSocket upgrade isn't available. Co-Authored-By: Claude Opus 4.8 --- src/lib/online/signalr-service.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/lib/online/signalr-service.ts b/src/lib/online/signalr-service.ts index 70add24..88c78cb 100644 --- a/src/lib/online/signalr-service.ts +++ b/src/lib/online/signalr-service.ts @@ -141,15 +141,10 @@ export class SignalrService implements OnlineService { private async connect(): Promise { if (this.conn || !this.token) return; const conn = new signalR.HubConnectionBuilder() - // Connect straight over WebSockets and SKIP the negotiate POST — some CDNs - // (WCDN) 404 the negotiate POST by method. The JWT rides the WS query - // string (server reads ?access_token for /hub). Real fix is to bypass the - // CDN for api.bargevasat.ir; this is a best-effort fallback. - .withUrl(`${SERVER}/hub/game`, { - accessTokenFactory: () => this.token ?? "", - skipNegotiation: true, - transport: signalR.HttpTransportType.WebSockets, - }) + // Normal negotiate flow → auto-picks the best transport (WS, else SSE / + // long-poll). Requires api.bargevasat.ir to BYPASS the CDN (WCDN 404s the + // negotiate POST); with the CDN bypassed this is the most robust path. + .withUrl(`${SERVER}/hub/game`, { accessTokenFactory: () => this.token ?? "" }) .withAutomaticReconnect() .configureLogging(signalR.LogLevel.Warning) .build();