gets and uses forwarded prefix in socket.ts

This commit is contained in:
Mose Müller 2024-09-26 21:10:56 +02:00
parent 52a798e4c8
commit 056c02c5a5

View File

@ -6,10 +6,20 @@ export const hostname =
process.env.NODE_ENV === "development" ? `localhost` : window.location.hostname;
export const port =
process.env.NODE_ENV === "development" ? 8001 : window.location.port;
// Get the forwarded prefix from the global variable
export const forwardedPrefix: string =
(window as any) /* eslint-disable-line @typescript-eslint/no-explicit-any */
.__FORWARDED_PREFIX__ || "";
export const authority = `${hostname}:${port}${forwardedPrefix}`;
const URL = `ws://${hostname}:${port}/`;
console.debug("Websocket: ", URL);
export const socket = io(URL, { path: "/ws/socket.io", transports: ["websocket"] });
export const socket = io(URL, {
path: `${forwardedPrefix}/ws/socket.io`,
transports: ["websocket"],
});
export const updateValue = (
serializedObject: SerializedObject,