Skip to content

Conversation

@joelhooks
Copy link
Contributor

Summary

Adds OPENCODE_APP_DIST env var to serve the web UI locally instead of proxying to app.opencode.ai.

Fixes blank page when accessing opencode web remotely (Tailscale, LAN, mobile) - the proxied JS tries to connect to localhost:4096 which doesn't exist on the remote device.

Also enables full offline capability.

Why it works

The default proxy to app.opencode.ai keeps the CLI lean and allows UI updates without CLI releases. But the hosted JS assumes localhost access, which breaks remote use and requires internet connectivity.

When serving locally via OPENCODE_APP_DIST:

  • location.hostname = your actual host (e.g., 192.168.1.x or Tailscale hostname)
  • Hostname check fails, falls through to window.location.origin
  • API and UI are on the same port with opencode web, so it just works
  • No internet required

Usage

cd packages/app && bun run build
OPENCODE_APP_DIST=$PWD/packages/app/dist opencode web --hostname 0.0.0.0 --port 7625

Port 7625 is arbitrary - use any available port. Access via http://<tailscale-hostname>:<port> or http://<lan-ip>:<port>.

Default behavior unchanged - still proxies unless env var is set.

Changes

  • server.ts - local SPA serving when OPENCODE_APP_DIST is set
  • .gitignore - ignore .hive/ directory
  • test/server/ - tests for health endpoints and app-dist serving

┌─────────────────────────────────────────┐
│  📡 REMOTE ACCESS UNLOCKED             │
├─────────────────────────────────────────┤
│                                         │
│   phone ──tailscale──▶ mac:7625        │
│                          │              │
│                     ┌────▼────┐         │
│                     │ opencode │        │
│                     │   web    │        │
│                     └────┬────┘         │
│                          │              │
│              ┌───────────▼───────────┐  │
│              │  local app/dist       │  │
│              │  (no proxy needed)    │  │
│              └───────────────────────┘  │
│                                         │
└─────────────────────────────────────────┘

Serve web UI locally instead of proxying to app.opencode.ai.
Fixes blank page on remote access (Tailscale, LAN, mobile).
Enables full offline capability.

- Add findAppDist() for local SPA serving
- Add .hive to .gitignore
- Add server tests for health endpoints and app-dist
@joelhooks
Copy link
Contributor Author

@rekram1-node what do you think? the deployed ui was broken for me today and causing issues and this would open up some options. I don't think it'd have unintentional consequences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant