24 lines
643 B
TypeScript
24 lines
643 B
TypeScript
const useCollaborationURL = (): string => {
|
|
const PATH = "/collab";
|
|
|
|
// TODO: revisit
|
|
/*
|
|
if (import.meta.env.VITE_COLLABORATION_URL) {
|
|
return import.meta.env.VITE_COLLABORATION_URL + PATH;
|
|
}
|
|
|
|
const API_URL = import.meta.env.VITE_BACKEND_API_URL;
|
|
if (!API_URL) {
|
|
throw new Error("Backend API URL is not defined");
|
|
}
|
|
*/
|
|
|
|
const API_URL = import.meta.env.DEV
|
|
? "http://localhost:3000"
|
|
: window.location.protocol + "//" + window.location.host;
|
|
|
|
const wsProtocol = API_URL.startsWith("https") ? "wss" : "ws";
|
|
return `${wsProtocol}://${API_URL.split("://")[1]}${PATH}`;
|
|
};
|
|
|
|
export default useCollaborationURL;
|