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";
const wsClient = createWSClient({
url: "ws://localhost:3001",
url: typeof window === "undefined" ? "ws://localhost:3001" : `ws://${window.location.hostname}:3001`,
});
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 dynamic from "next/dynamic";
import { DynamicBreadcrumb } from "~/components/navigation/dynamic-breadcrumb";
import { fullHeightWithoutHeaderAndFooter } from "~/constants";
import { createMetaTitle } from "~/metadata";
import { ClientSideTerminalComponent } from "./client";
export async function generateMetadata() {
const t = await getScopedI18n("management");
@@ -18,10 +17,6 @@ export async function generateMetadata() {
};
}
const ClientSideTerminalComponent = dynamic(() => import("./terminal"), {
ssr: false,
});
export default function LogsManagementPage() {
return (
<>

View File

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