[WEB-2559] fix: live server URL generation for self-managed instances. (#5733)
This commit is contained in:
parent
96dc9db237
commit
62c45f3bb1
2 changed files with 23 additions and 17 deletions
|
|
@ -18,7 +18,7 @@ import { IUserLite } from "@plane/types";
|
||||||
import { Row } from "@plane/ui";
|
import { Row } from "@plane/ui";
|
||||||
import { PageContentBrowser, PageContentLoader, PageEditorTitle } from "@/components/pages";
|
import { PageContentBrowser, PageContentLoader, PageEditorTitle } from "@/components/pages";
|
||||||
// helpers
|
// helpers
|
||||||
import { cn, LIVE_URL } from "@/helpers/common.helper";
|
import { cn, LIVE_BASE_PATH, LIVE_BASE_URL } from "@/helpers/common.helper";
|
||||||
import { generateRandomColor } from "@/helpers/string.helper";
|
import { generateRandomColor } from "@/helpers/string.helper";
|
||||||
// hooks
|
// hooks
|
||||||
import { useMember, useMention, useUser, useWorkspace } from "@/hooks/store";
|
import { useMember, useMention, useUser, useWorkspace } from "@/hooks/store";
|
||||||
|
|
@ -112,24 +112,30 @@ export const PageEditorBody: React.FC<Props> = observer((props) => {
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
const realtimeConfig: TRealtimeConfig = useMemo(() => {
|
const realtimeConfig: TRealtimeConfig | undefined = useMemo(() => {
|
||||||
// Construct the WebSocket Collaboration URL
|
// Construct the WebSocket Collaboration URL
|
||||||
const WS_LIVE_URL = new URL(LIVE_URL);
|
try {
|
||||||
const isSecureEnvironment = window.location.protocol === "https:";
|
const LIVE_SERVER_BASE_URL = LIVE_BASE_URL ?? window.location.origin;
|
||||||
WS_LIVE_URL.protocol = isSecureEnvironment ? "wss" : "ws";
|
const WS_LIVE_URL = new URL(`${LIVE_SERVER_BASE_URL}${LIVE_BASE_PATH}`);
|
||||||
WS_LIVE_URL.pathname = "collaboration";
|
const isSecureEnvironment = window.location.protocol === "https:";
|
||||||
|
WS_LIVE_URL.protocol = isSecureEnvironment ? "wss" : "ws";
|
||||||
return {
|
WS_LIVE_URL.pathname = "collaboration";
|
||||||
url: WS_LIVE_URL.toString(),
|
// Construct realtime config
|
||||||
queryParams: {
|
return {
|
||||||
workspaceSlug: workspaceSlug?.toString(),
|
url: WS_LIVE_URL.toString(),
|
||||||
projectId: projectId?.toString(),
|
queryParams: {
|
||||||
documentType: "project_page",
|
workspaceSlug: workspaceSlug?.toString(),
|
||||||
},
|
projectId: projectId?.toString(),
|
||||||
};
|
documentType: "project_page",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error creating realtime config", error);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
}, [projectId, workspaceSlug]);
|
}, [projectId, workspaceSlug]);
|
||||||
|
|
||||||
if (pageId === undefined) return <PageContentLoader />;
|
if (pageId === undefined || !realtimeConfig) return <PageContentLoader />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center h-full w-full overflow-y-auto">
|
<div className="flex items-center h-full w-full overflow-y-auto">
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ export const ADMIN_BASE_PATH = process.env.NEXT_PUBLIC_ADMIN_BASE_PATH || "";
|
||||||
export const SPACE_BASE_URL = process.env.NEXT_PUBLIC_SPACE_BASE_URL || "";
|
export const SPACE_BASE_URL = process.env.NEXT_PUBLIC_SPACE_BASE_URL || "";
|
||||||
export const SPACE_BASE_PATH = process.env.NEXT_PUBLIC_SPACE_BASE_PATH || "";
|
export const SPACE_BASE_PATH = process.env.NEXT_PUBLIC_SPACE_BASE_PATH || "";
|
||||||
|
|
||||||
const LIVE_BASE_URL = process.env.NEXT_PUBLIC_LIVE_BASE_URL || "";
|
export const LIVE_BASE_URL = process.env.NEXT_PUBLIC_LIVE_BASE_URL || "";
|
||||||
export const LIVE_BASE_PATH = process.env.NEXT_PUBLIC_LIVE_BASE_PATH || "";
|
export const LIVE_BASE_PATH = process.env.NEXT_PUBLIC_LIVE_BASE_PATH || "";
|
||||||
export const LIVE_URL = `${LIVE_BASE_URL}${LIVE_BASE_PATH}`;
|
export const LIVE_URL = `${LIVE_BASE_URL}${LIVE_BASE_PATH}`;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue