fix collaboration websocket

This commit is contained in:
Philipinho
2024-09-03 10:48:47 +01:00
parent 8af2d4e8cf
commit dc3ce27762

View File

@ -7,23 +7,27 @@ declare global {
export function getAppUrl(): string { export function getAppUrl(): string {
//let appUrl = window.CONFIG?.APP_URL || process.env.APP_URL; //let appUrl = window.CONFIG?.APP_URL || process.env.APP_URL;
// if (import.meta.env.DEV) { // if (import.meta.env.DEV) {
// return appUrl || "http://localhost:3000"; // return appUrl || "http://localhost:3000";
//} //}
return `${window.location.protocol}//${window.location.host}`; return `${window.location.protocol}//${window.location.host}`;
} }
export function getBackendUrl(): string { export function getBackendUrl(): string {
return getAppUrl() + "/api"; return getAppUrl() + '/api';
} }
export function getCollaborationUrl(): string { export function getCollaborationUrl(): string {
const COLLAB_PATH = "/collab"; const COLLAB_PATH = '/collab';
const url = process.env.APP_URL || getAppUrl();
const wsProtocol = url.startsWith("https") ? "wss" : "ws"; let url = getAppUrl();
return `${wsProtocol}://${url.split("://")[1]}${COLLAB_PATH}`; if (import.meta.env.DEV) {
url = process.env.APP_URL;
}
const wsProtocol = url.startsWith('https') ? 'wss' : 'ws';
return `${wsProtocol}://${url.split('://')[1]}${COLLAB_PATH}`;
} }
export function getAvatarUrl(avatarUrl: string) { export function getAvatarUrl(avatarUrl: string) {
@ -31,17 +35,17 @@ export function getAvatarUrl(avatarUrl: string) {
return null; return null;
} }
if (avatarUrl?.startsWith("http")) { if (avatarUrl?.startsWith('http')) {
return avatarUrl; return avatarUrl;
} }
return getBackendUrl() + "/attachments/img/avatar/" + avatarUrl; return getBackendUrl() + '/attachments/img/avatar/' + avatarUrl;
} }
export function getSpaceUrl(spaceSlug: string) { export function getSpaceUrl(spaceSlug: string) {
return "/s/" + spaceSlug; return '/s/' + spaceSlug;
} }
export function getFileUrl(src: string) { export function getFileUrl(src: string) {
return src?.startsWith("/files/") ? getBackendUrl() + src : src; return src?.startsWith('/files/') ? getBackendUrl() + src : src;
} }