add websocket

This commit is contained in:
aurinex
2025-12-22 16:42:37 +05:00
parent 4b8e535c58
commit 6caa563b41
5 changed files with 318 additions and 60 deletions

View File

@ -0,0 +1,14 @@
export function getWsBaseUrl(): string {
// 1) если ты пробрасываешь конфиг в window
const w = window as any;
if (w.__ENV__?.WS_BASE) return String(w.__ENV__.WS_BASE);
// 2) если открыто с https/http — строим ws/wss автоматически
if (typeof window !== 'undefined' && window.location?.origin) {
const origin = window.location.origin; // http(s)://host
return origin.replace(/^http/, 'ws');
}
// 3) дефолт
return 'wss://minecraft.api.popa-popa.ru';
}