Skip to content

Commit

Permalink
Allow users to proxy Portal behind a load balancer
Browse files Browse the repository at this point in the history
  • Loading branch information
djblue committed May 18, 2022
1 parent fdea983 commit 37d2a88
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/portal/ui/rpc.cljs
Expand Up @@ -159,6 +159,9 @@
(defn- get-host []
(if (exists? js/PORTAL_HOST) js/PORTAL_HOST js/location.host))

(defn- get-proto []
(if (= (.-protocol js/location) "https:") "wss:" "ws:"))

(defn- connect []
(if-let [ws @ws-promise]
ws
Expand All @@ -167,7 +170,7 @@
(js/Promise.
(fn [resolve reject]
(when-let [chan (js/WebSocket.
(str "ws://" (get-host) "/rpc?" (get-session)))]
(str (get-proto) "//" (get-host) "/rpc?" (get-session)))]
(set! (.-onmessage chan) #(dispatch (read (.-data %))
(fn [message]
(send! message))))
Expand Down

0 comments on commit 37d2a88

Please sign in to comment.