2022-10-31 13:25:32 +00:00
|
|
|
// const WS_BASE = 'ws://localhost:3000/ws/';
|
|
|
|
|
|
|
|
export function wsUrl(id: string) {
|
2022-11-01 10:00:17 +00:00
|
|
|
if (import.meta.env.VITE_WS_BASE) {
|
|
|
|
return import.meta.env.VITE_WS_BASE + id;
|
2022-10-31 13:25:32 +00:00
|
|
|
} else {
|
|
|
|
const loc = window.location;
|
|
|
|
let newUri = loc.protocol === "https:" ? "wss://" : "ws://";
|
|
|
|
newUri += loc.host + '/ws/' + id;
|
|
|
|
return newUri;
|
|
|
|
}
|
|
|
|
}
|