chs/src-web/constants.ts

13 lines
355 B
TypeScript
Raw Normal View History

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