Skip to content

Commit 6a093c3

Browse files
fix(compose): point the browser socket at :3002 so it stops reconnecting
The stack publishes the app on 3000 and realtime on 3002 with no reverse proxy between them, but NEXT_PUBLIC_SOCKET_URL defaulted to empty — which tells the browser client to use the page origin. :3000/socket.io answers 308 (a Next redirect), not a Socket.IO handshake, so the client failed and retried forever. Default it to http://localhost:3002; a proxied deployment overrides it (or sets it empty to use the page origin). Also give COPILOT_API_KEY and SIM_AGENT_API_URL empty defaults so every compose command stops printing 'variable is not set' warnings. The app already falls back to the prod copilot backend when SIM_AGENT_API_URL is blank.
1 parent 2243cc5 commit 6a093c3

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

docker-compose.local.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ services:
2222
- API_ENCRYPTION_KEY=${API_ENCRYPTION_KEY:-}
2323
- INTERNAL_API_SECRET=${INTERNAL_API_SECRET:-dev-internal-api-secret-min-32-chars}
2424
- REDIS_URL=${REDIS_URL:-redis://redis:6379}
25-
- COPILOT_API_KEY=${COPILOT_API_KEY}
26-
- SIM_AGENT_API_URL=${SIM_AGENT_API_URL}
25+
- COPILOT_API_KEY=${COPILOT_API_KEY:-}
26+
- SIM_AGENT_API_URL=${SIM_AGENT_API_URL:-}
2727
- OLLAMA_URL=${OLLAMA_URL:-http://localhost:11434}
2828
- SOCKET_SERVER_URL=${SOCKET_SERVER_URL:-http://realtime:3002}
29-
- NEXT_PUBLIC_SOCKET_URL=${NEXT_PUBLIC_SOCKET_URL:-}
29+
# Published on 3002 with no proxy in front, so the browser must target it
30+
# directly; empty would fall back to the page origin, where /socket.io
31+
# answers 308 and the socket reconnects forever.
32+
- NEXT_PUBLIC_SOCKET_URL=${NEXT_PUBLIC_SOCKET_URL:-http://localhost:3002}
3033
depends_on:
3134
db:
3235
condition: service_healthy

docker-compose.prod.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,18 @@ services:
3131
- API_ENCRYPTION_KEY=${API_ENCRYPTION_KEY:-}
3232
- INTERNAL_API_SECRET=${INTERNAL_API_SECRET}
3333
- REDIS_URL=${REDIS_URL:-redis://redis:6379}
34-
- COPILOT_API_KEY=${COPILOT_API_KEY}
35-
- SIM_AGENT_API_URL=${SIM_AGENT_API_URL}
34+
- COPILOT_API_KEY=${COPILOT_API_KEY:-}
35+
- SIM_AGENT_API_URL=${SIM_AGENT_API_URL:-}
3636
- OLLAMA_URL=${OLLAMA_URL:-http://localhost:11434}
3737
- SOCKET_SERVER_URL=${SOCKET_SERVER_URL:-http://realtime:3002}
38-
# NEXT_PUBLIC_SOCKET_URL is read by the browser. Leaving it unset lets the
39-
# client default to the page's own origin (assumes the reverse proxy routes
40-
# /socket.io). Set it explicitly only when the realtime service is on a
41-
# different host:port from the app (e.g. wss://socket.example.com).
42-
- NEXT_PUBLIC_SOCKET_URL=${NEXT_PUBLIC_SOCKET_URL:-}
38+
# NEXT_PUBLIC_SOCKET_URL is read by the browser. This stack publishes the
39+
# app on 3000 and realtime on 3002 with no reverse proxy between them, so
40+
# it must point at 3002 — left empty the client falls back to the page
41+
# origin, where /socket.io answers 308 instead of a handshake and the
42+
# socket reconnects forever. Override when a proxy fronts both on one
43+
# origin (set it to that origin, or empty to use the page origin), or when
44+
# realtime is elsewhere (e.g. wss://socket.example.com).
45+
- NEXT_PUBLIC_SOCKET_URL=${NEXT_PUBLIC_SOCKET_URL:-http://localhost:3002}
4346
- ADMISSION_GATE_MAX_INFLIGHT=${ADMISSION_GATE_MAX_INFLIGHT:-500}
4447
depends_on:
4548
db:

0 commit comments

Comments
 (0)