Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion client/src/components/Terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ export function Terminal({ sessionId, color, nodeId }: TerminalProps) {

// Connect WebSocket with small delay to allow session to be ready
const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
const wsUrl = `${protocol}//${window.location.host}/ws?sessionId=${sessionId}`;
// In dev, Vite's proxy can't relay Bun's WebSocket upgrade response, so connect
// directly to the backend. In production (single-server) the backend serves the
// client itself, so the current host already points at the backend.
const wsHost = import.meta.env.DEV
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
? `${window.location.hostname}:${import.meta.env.VITE_BACKEND_PORT ?? 6968}`
: window.location.host;
const wsUrl = `${protocol}//${wsHost}/ws?sessionId=${sessionId}`;

let ws: WebSocket | null = null;
let isFirstMessage = true;
Expand Down
7 changes: 3 additions & 4 deletions client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ export default defineConfig({
target: "http://localhost:6968",
changeOrigin: true,
},
"/ws": {
target: "ws://localhost:6968",
ws: true,
},
// NOTE: /ws is intentionally not proxied. Vite's http-proxy cannot relay
// Bun.serve's WebSocket upgrade response, so the client connects directly
// to the backend in dev (see Terminal.tsx).
},
},
build: {
Expand Down