fix: Export WS_URL from websocket client
This commit is contained in:
parent
4ab6400a87
commit
256d69ec0f
@ -108,3 +108,19 @@ export class WebSocketClient {
|
|||||||
// Create singleton instance
|
// Create singleton instance
|
||||||
export const wsClient = new WebSocketClient();
|
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`;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user