Skip to content

Commit

Permalink
fix(ui): websocket on port other than 80/443 on k8s (#2816)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahargl authored Dec 12, 2024
1 parent df95354 commit c5b3e9c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions keep-ui/utils/hooks/usePusher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ export const useWebsocket = () => {
!configData.PUSHER_HOST.includes("://") &&
!["localhost", "127.0.0.1"].includes(configData.PUSHER_HOST);

// if relative, get the relative port:
let port = configData.PUSHER_PORT;
if (isRelativeHostAndNotLocal) {
// Handle case where port is empty string (default ports 80/443)
if (window.location.port) {
port = parseInt(window.location.port, 10);
} else {
// Use default ports based on protocol
port = window.location.protocol === "https:" ? 443 : 80;
}
}

console.log(
"useWebsocket: isRelativeHostAndNotLocal:",
isRelativeHostAndNotLocal
Expand All @@ -42,11 +54,7 @@ export const useWebsocket = () => {
? window.location.hostname
: configData.PUSHER_HOST,
wsPath: isRelativeHostAndNotLocal ? configData.PUSHER_HOST : "",
wsPort: isRelativeHostAndNotLocal
? window.location.protocol === "https:"
? 443
: 80
: configData.PUSHER_PORT,
wsPort: isRelativeHostAndNotLocal ? port : configData.PUSHER_PORT,
forceTLS: window.location.protocol === "https:",
disableStats: true,
enabledTransports: ["ws", "wss"],
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "keep"
version = "0.31.6"
version = "0.31.7"
description = "Alerting. for developers, by developers."
authors = ["Keep Alerting LTD"]
packages = [{include = "keep"}]
Expand Down

0 comments on commit c5b3e9c

Please sign in to comment.