summaryrefslogtreecommitdiffstats
path: root/web/play/src
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-08 11:53:04 +0100
committersalmonik <salmonik@tuta.io>2026-11-08 11:53:04 +0100
commit0bace1ce8826a9a1be4003681fab5138f174c275 (patch)
treebd191ef204486c950e8407718cb2ddb1dad64e44 /web/play/src
parentweb: link the GPL source from the play page; normalise gateway config (diff)
downloadzagan-bet-0bace1ce8826a9a1be4003681fab5138f174c275.tar.gz
zagan-bet-0bace1ce8826a9a1be4003681fab5138f174c275.zip
dev: add a no-nginx browser stack script
scripts/dev-web.sh builds the server, gateway and app, creates target/dev-web/identity, and runs the game server, webd and a loopback static server. The app accepts a ?ws= override only on loopback so the page and gateway can sit on different local ports; production stays same-origin at /ws.
Diffstat (limited to '')
-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) {