summaryrefslogtreecommitdiffstats
path: root/web/play/src
diff options
context:
space:
mode:
Diffstat (limited to 'web/play/src')
-rw-r--r--web/play/src/main.ts15
1 files changed, 14 insertions, 1 deletions
diff --git a/web/play/src/main.ts b/web/play/src/main.ts
index 15eecf5..690d827 100644
--- a/web/play/src/main.ts
+++ b/web/play/src/main.ts
@@ -63,7 +63,20 @@ const descriptions: Record<string, string> = {
63const basePath = location.pathname.includes("/play/") 63const basePath = location.pathname.includes("/play/")
64 ? location.pathname.slice(0, location.pathname.indexOf("/play/")) 64 ? location.pathname.slice(0, location.pathname.indexOf("/play/"))
65 : ""; 65 : "";
66const wsUrl = `${location.protocol === "https:" ? "wss" : "ws"}://${location.host}${basePath}/ws`; 66const defaultWsUrl = `${location.protocol === "https:" ? "wss" : "ws"}://${location.host}${basePath}/ws`;
67
68// A local-only escape hatch for `scripts/dev-web.sh`, which serves the static
69// page and the gateway on different loopback ports. Never honour ?ws= on a
70// real host: it would let a crafted link send a password hash elsewhere.
71const devWs = new URLSearchParams(location.search).get("ws");
72const loopback =
73 location.hostname === "127.0.0.1" ||
74 location.hostname === "localhost" ||
75 location.hostname === "::1";
76const wsUrl =
77 devWs && loopback && (devWs.startsWith("ws://") || devWs.startsWith("wss://"))
78 ? devWs
79 : defaultWsUrl;
67 80
68const gateway = new Gateway(wsUrl, { 81const gateway = new Gateway(wsUrl, {
69 onHello(hello) { 82 onHello(hello) {