feat: standalone collab server (#767)

* feat: standalone collab server

* * custom collab server port env
* fix collab start script command

* * API prefix
* Log startup PORT

* Tweak collab debounce
This commit is contained in:
Philip Okugbe
2025-02-25 13:15:51 +00:00
committed by GitHub
parent 08829ea721
commit 4b9ab4f63c
10 changed files with 119 additions and 22 deletions

View File

@ -19,15 +19,13 @@ export function getBackendUrl(): string {
}
export function getCollaborationUrl(): string {
const COLLAB_PATH = "/collab";
const baseUrl =
getConfigValue("COLLAB_URL") ||
(import.meta.env.DEV ? process.env.APP_URL : getAppUrl());
let url = getAppUrl();
if (import.meta.env.DEV) {
url = process.env.APP_URL;
}
const wsProtocol = url.startsWith("https") ? "wss" : "ws";
return `${wsProtocol}://${url.split("://")[1]}${COLLAB_PATH}`;
const collabUrl = new URL("/collab", baseUrl);
collabUrl.protocol = collabUrl.protocol === "https:" ? "wss:" : "ws:";
return collabUrl.toString();
}
export function getAvatarUrl(avatarUrl: string) {

View File

@ -5,16 +5,21 @@ import * as path from "path";
export const envPath = path.resolve(process.cwd(), "..", "..");
export default defineConfig(({ mode }) => {
const { APP_URL, FILE_UPLOAD_SIZE_LIMIT, DRAWIO_URL } = loadEnv(mode, envPath, "");
const { APP_URL, FILE_UPLOAD_SIZE_LIMIT, DRAWIO_URL, COLLAB_URL } = loadEnv(
mode,
envPath,
"",
);
return {
define: {
"process.env": {
APP_URL,
FILE_UPLOAD_SIZE_LIMIT,
DRAWIO_URL
DRAWIO_URL,
COLLAB_URL,
},
'APP_VERSION': JSON.stringify(process.env.npm_package_version),
APP_VERSION: JSON.stringify(process.env.npm_package_version),
},
plugins: [react()],
resolve: {