fix: add type definition for WebSocket URL and remove redundant protocol declaration

This commit is contained in:
Haileyesus
2026-01-31 11:54:24 +03:00
parent f6970d6ad9
commit 5a4813f9bd

View File

@@ -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)}`;
}