fix: Export WS_URL from websocket client

This commit is contained in:
Primakov Alexandr Alexandrovich 2025-10-13 01:02:22 +03:00
parent 4ab6400a87
commit 256d69ec0f

View File

@ -108,3 +108,19 @@ export class WebSocketClient {
// Create singleton instance
export const wsClient = new WebSocketClient();
// Export helper to get WS URL
export const getWebSocketUrl = (): string => {
// Если задан VITE_WS_URL, используем его
if (import.meta.env.VITE_WS_URL) {
return import.meta.env.VITE_WS_URL;
}
// Иначе определяем автоматически на основе текущего location
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const host = window.location.host;
return `${protocol}//${host}`;
};
// Export WS_URL for direct usage
export const WS_URL = `${getWebSocketUrl()}/ws/reviews`;