guandan.dev

guandan.dev

https://git.tonybtw.com/guandan.dev.git git://git.tonybtw.com/guandan.dev.git

Use env var for websocket URL (no secrets)

Commit
592664c88fd31a1371ad3267bcc8a48efea8c741
Parent
dfcd8ae
Author
tonybanters <tonyoutoften@gmail.com>
Date
2026-01-27 06:54:47

Diff

diff --git a/client/.env.development b/client/.env.development
new file mode 100644
index 0000000..495b484
--- /dev/null
+++ b/client/.env.development
@@ -0,0 +1 @@
+VITE_WS_URL=ws://localhost:8080/ws
diff --git a/client/.env.production b/client/.env.production
new file mode 100644
index 0000000..0815724
--- /dev/null
+++ b/client/.env.production
@@ -0,0 +1 @@
+VITE_WS_URL=wss://guandan.dev/ws
diff --git a/client/src/App.tsx b/client/src/App.tsx
index 6614b26..9d5a689 100644
--- a/client/src/App.tsx
+++ b/client/src/App.tsx
@@ -41,7 +41,7 @@ interface Error_Payload {
 }
 
 export default function App() {
-  const ws_url = `ws://${window.location.hostname}:8080/ws`
+  const ws_url = import.meta.env.VITE_WS_URL
   const { connected, send, on } = use_websocket(ws_url)
 
   const [room_id, set_room_id] = useState<string | null>(null)