12 lines
365 B
TypeScript
12 lines
365 B
TypeScript
// const WS_BASE = 'ws://localhost:3000/ws/';
|
|
|
|
export function wsUrl(id: string) {
|
|
if (import.meta.env.VITE_WS_BASE) {
|
|
return import.meta.env.VITE_WS_BASE + id;
|
|
} else {
|
|
const loc = window.location;
|
|
let newUri = loc.protocol === "https:" ? "wss://" : "ws://";
|
|
newUri += loc.host + '/ws/' + id;
|
|
return newUri;
|
|
}
|
|
}
|