File size: 330 Bytes
f4542ce
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
const BASE = import.meta.env.VITE_API_URL || "";

export function apiUrl(path) {
  return `${BASE}${path}`;
}

export function wsUrl(path) {
  if (BASE) {
    return `${BASE.replace(/^http/, "ws")}${path}`;
  }
  const protocol = location.protocol === "https:" ? "wss:" : "ws:";
  return `${protocol}//${location.host}${path}`;
}