From 256d69ec0f84a8d9227a06dc03ad4c0c7bd94622 Mon Sep 17 00:00:00 2001 From: Primakov Alexandr Alexandrovich Date: Mon, 13 Oct 2025 01:02:22 +0300 Subject: [PATCH] fix: Export WS_URL from websocket client --- frontend/src/api/websocket.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/frontend/src/api/websocket.ts b/frontend/src/api/websocket.ts index 9f13238..69b03a6 100644 --- a/frontend/src/api/websocket.ts +++ b/frontend/src/api/websocket.ts @@ -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`; +