Skip to content

Commit

Permalink
chore(frontend): define socket protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
denys-holub authored and pashagolub committed Aug 27, 2024
1 parent 7644194 commit e647dd9
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions internal/webui/src/queries/Log/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { useWebSocket } from "react-use-websocket/dist/lib/use-websocket";
import { getToken } from "services/Token";

const socketUrl = `ws://${window.location.host}/log`;
const token = getToken();

export const useLogs = () => useWebSocket(socketUrl, {
queryParams: {
"Token": token ? token : ""
}
});
export const useLogs = () => {
const socketProtocol = window.location.protocol === "https:" ? "wss://" : "ws://";
const token = getToken() || "";

return useWebSocket(
`${socketProtocol}${window.location.host}/log`,
{
queryParams: {
"Token": token,
},
},
);
};

0 comments on commit e647dd9

Please sign in to comment.