From 5a4813f9bdf1c8406b40fded4e7a386fa573e9f5 Mon Sep 17 00:00:00 2001 From: Haileyesus Date: Sat, 31 Jan 2026 11:54:24 +0300 Subject: [PATCH] fix: add type definition for WebSocket URL and remove redundant protocol declaration --- src/contexts/WebSocketContext.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/contexts/WebSocketContext.tsx b/src/contexts/WebSocketContext.tsx index dbdc9ad..04bfcd5 100644 --- a/src/contexts/WebSocketContext.tsx +++ b/src/contexts/WebSocketContext.tsx @@ -41,11 +41,11 @@ const useWebSocketProviderState = () => { const isPlatform = import.meta.env.VITE_IS_PLATFORM === 'true'; // Construct WebSocket URL - let wsUrl; + let wsUrl: string; + const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; if (isPlatform) { // Platform mode: Use same domain as the page (goes through proxy) - const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; wsUrl = `${protocol}//${window.location.host}/ws`; } else { // OSS mode: Connect to same host:port that served the page @@ -54,8 +54,6 @@ const useWebSocketProviderState = () => { console.warn('No authentication token found for WebSocket connection'); return; } - - const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; wsUrl = `${protocol}//${window.location.host}/ws?token=${encodeURIComponent(token)}`; }