[PR #6215] fix(web): add OPENCODE_APP_DIST for remote access #11781

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

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

State: closed
Merged: No


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
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6215 **State:** closed **Merged:** No --- ## 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 ```bash 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
yindo added the pull-request label 2026-02-16 18:16:43 -05:00
yindo closed this issue 2026-02-16 18:16:43 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11781