fix: wevbsocket url is always localhost (#1072)

This commit is contained in:
Meier Lukas
2024-09-06 21:11:58 +02:00
committed by GitHub
parent 753d091dbb
commit 8c205535eb
4 changed files with 14 additions and 9 deletions

View File

@@ -12,7 +12,7 @@ import type { AppRouter } from "@homarr/api";
import { clientApi } from "@homarr/api/client"; import { clientApi } from "@homarr/api/client";
const wsClient = createWSClient({ const wsClient = createWSClient({
url: "ws://localhost:3001", url: typeof window === "undefined" ? "ws://localhost:3001" : `ws://${window.location.hostname}:3001`,
}); });
export function TRPCReactProvider(props: PropsWithChildren) { export function TRPCReactProvider(props: PropsWithChildren) {

View File

@@ -0,0 +1,10 @@
"use client";
import dynamic from "next/dynamic";
export const ClientSideTerminalComponent = dynamic(
() => import("./terminal").then(({ TerminalComponent }) => TerminalComponent),
{
ssr: false,
},
);

View File

@@ -4,11 +4,10 @@ import { getScopedI18n } from "@homarr/translation/server";
import "@xterm/xterm/css/xterm.css"; import "@xterm/xterm/css/xterm.css";
import dynamic from "next/dynamic";
import { DynamicBreadcrumb } from "~/components/navigation/dynamic-breadcrumb"; import { DynamicBreadcrumb } from "~/components/navigation/dynamic-breadcrumb";
import { fullHeightWithoutHeaderAndFooter } from "~/constants"; import { fullHeightWithoutHeaderAndFooter } from "~/constants";
import { createMetaTitle } from "~/metadata"; import { createMetaTitle } from "~/metadata";
import { ClientSideTerminalComponent } from "./client";
export async function generateMetadata() { export async function generateMetadata() {
const t = await getScopedI18n("management"); const t = await getScopedI18n("management");
@@ -18,10 +17,6 @@ export async function generateMetadata() {
}; };
} }
const ClientSideTerminalComponent = dynamic(() => import("./terminal"), {
ssr: false,
});
export default function LogsManagementPage() { export default function LogsManagementPage() {
return ( return (
<> <>

View File

@@ -10,7 +10,7 @@ import { clientApi } from "@homarr/api/client";
import classes from "./terminal.module.css"; import classes from "./terminal.module.css";
export default function TerminalComponent() { export const TerminalComponent = () => {
const ref = useRef<HTMLDivElement>(null); const ref = useRef<HTMLDivElement>(null);
const terminalRef = useRef<Terminal>(); const terminalRef = useRef<Terminal>();
@@ -54,4 +54,4 @@ export default function TerminalComponent() {
}; };
}, []); }, []);
return <Box ref={ref} id="terminal" className={classes.outerTerminal} h="100%"></Box>; return <Box ref={ref} id="terminal" className={classes.outerTerminal} h="100%"></Box>;
} };