[PR #6107] fix: use hostname for serving #11738

Closed
opened 2026-02-16 18:16:40 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6107

State: closed
Merged: No


Fixes #5844
Fixes #6063

When running opencode web --hostname 0.0.0.0 and accessing via a network IP,
the terminal WebSocket fails because the SDK URL defaults to http://localhost:4096.

Changed the fallback in packages/app/src/app.tsx from hardcoded localhost:4096
to window.location.origin, which correctly uses the hostname and port the user
accessed the page with.

This only affects the web production fallback case - desktop (Tauri), opencode.ai
console, and dev mode all hit earlier conditions and are unaffected.

Testing

run the app with:
cd packages/opencode && bun dev web --hostname 0.0.0.0 --port 4096

run opencode with:
VITE_OPENCODE_SERVER_HOST=0.0.0.0 VITE_OPENCODE_SERVER_PORT=4096 bun dev

then access the app from another network device at <hostname/ip>:3000 and it should work

alternatively

build first with
cd packages/app && bunx vite build

run opencode
cd packages/opencode && bun dev web --hostname 0.0.0.0 --port 4096 --app-dir ../app/dist

and access with <hostname/ip>:4096, works from accessing from another device.

Related issues

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6107 **State:** closed **Merged:** No --- Fixes #5844 Fixes #6063 When running `opencode web --hostname 0.0.0.0` and accessing via a network IP, the terminal WebSocket fails because the SDK URL defaults to `http://localhost:4096`. Changed the fallback in `packages/app/src/app.tsx` from hardcoded `localhost:4096` to `window.location.origin`, which correctly uses the hostname and port the user accessed the page with. This only affects the web production fallback case - desktop (Tauri), opencode.ai console, and dev mode all hit earlier conditions and are unaffected. ## Testing run the app with: `cd packages/opencode && bun dev web --hostname 0.0.0.0 --port 4096` run opencode with: `VITE_OPENCODE_SERVER_HOST=0.0.0.0 VITE_OPENCODE_SERVER_PORT=4096 bun dev` then access the app from another network device at `<hostname/ip>:3000` and it should work ### alternatively build first with `cd packages/app && bunx vite build` run opencode `cd packages/opencode && bun dev web --hostname 0.0.0.0 --port 4096 --app-dir ../app/dist` and access with `<hostname/ip>:4096`, works from accessing from another device. ## Related issues - https://github.com/sst/opencode/pull/5967 - https://github.com/sst/opencode/issues/5928 - https://github.com/sst/opencode/pull/6158
yindo added the pull-request label 2026-02-16 18:16:40 -05:00
yindo closed this issue 2026-02-16 18:16:40 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11738