mirror of
https://github.com/ajnart/homarr.git
synced 2026-02-27 00:40:58 +01:00
fix: local websocket url wrong (#1328)
This commit is contained in:
@@ -19,11 +19,23 @@ import superjson from "superjson";
|
||||
import type { AppRouter } from "@homarr/api";
|
||||
import { clientApi } from "@homarr/api/client";
|
||||
|
||||
import { env } from "~/env.mjs";
|
||||
|
||||
const constructWebsocketUrl = () => {
|
||||
const fallback = "ws://localhost:3001/websockets";
|
||||
if (typeof window === "undefined") {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
if (env.NODE_ENV === "development") {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
return `ws://${window.location.hostname}:${window.location.port}/websockets`;
|
||||
};
|
||||
|
||||
const wsClient = createWSClient({
|
||||
url:
|
||||
typeof window === "undefined"
|
||||
? "ws://localhost:3001/websockets"
|
||||
: `ws://${window.location.hostname}:${window.location.port}/websockets`,
|
||||
url: constructWebsocketUrl(),
|
||||
});
|
||||
|
||||
export function TRPCReactProvider(props: PropsWithChildren) {
|
||||
|
||||
Reference in New Issue
Block a user