From 57536819c3558daeafb667366749652d7631c64e Mon Sep 17 00:00:00 2001 From: Michael Camilleri Date: Sat, 21 Jan 2023 02:57:33 +0900 Subject: [PATCH] Use window.location.hostname for WebSocket connection (#49) * Use window.location.hostname for WebSocket connection * Update CHANGELOG --- CHANGELOG.md | 4 ++++ src/scittle/nrepl.cljs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87eacab..86c83bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ [Scittle](https://github.com/babashka/scittle): execute Clojure(Script) directly from browser script tags via SCI! +## Unreleased + +- Use `window.location.hostname` for WebSocket connection + ## v0.5.14 (2023-01-05) - Fix destructuring in `defmethod` (by upgrading SCI) diff --git a/src/scittle/nrepl.cljs b/src/scittle/nrepl.cljs index fffa295..846fdd9 100644 --- a/src/scittle/nrepl.cljs +++ b/src/scittle/nrepl.cljs @@ -36,7 +36,7 @@ (when-let [ws-port (.-SCITTLE_NREPL_WEBSOCKET_PORT js/window)] (set! (.-ws_nrepl js/window) - (new js/WebSocket (ws-url "localhost" ws-port "_nrepl")))) + (new js/WebSocket (ws-url (.-hostname (.-location js/window)) ws-port "_nrepl")))) (when-let [ws (nrepl-websocket)] (prn :ws ws)