Skip to content

Commit 54a26c8

Browse files
committed
Use wss when window.location is https
1 parent 9571040 commit 54a26c8

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

resources/public/assets/js/compiled/main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/clojurescript/flow_monitor_ui/config.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
(goog-define alert-timeout-ms 3000)
88

99
;; ====
10-
(defonce websocket-uri-base "ws://localhost:")
10+
(defonce websocket-uri-base "localhost:")
1111
(defonce websocket-uri-route "/flow-socket")

src/clojurescript/flow_monitor_ui/global.cljs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,10 @@
185185
(get-in db [:query-params])))
186186

187187
(defn make-websocket! []
188-
(let [params (<sub [::get-params])]
188+
(let [params (<sub [::get-params])
189+
protocol (if (= (.-protocol js/window.location) "https:") "wss://" "ws://")]
189190
(if (not (:ws-connected @global-state))
190-
(if-let [chan (js/WebSocket. (str websocket-uri-base (or (:port params) 9998) websocket-uri-route))]
191+
(if-let [chan (js/WebSocket. (str protocol websocket-uri-base (or (:port params) 9998) websocket-uri-route))]
191192
(do
192193
(swap! global-state assoc :ws-connected true)
193194
(set! (.-onmessage chan) (fn [msg]

0 commit comments

Comments
 (0)