opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix: use hostname for serving

Open jhsu opened this issue 2 weeks ago • 0 comments

Fixes #5844

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

jhsu avatar Dec 24 '25 16:12 jhsu