Guide
Run it end to end.
The bridge is an ordinary Node service. Everything below is a copy and paste, no editor required.
Start OpenCode
Run the local service. The bridge discovers it on loopback.
Run the bridge
Install, set AUTH_TOKEN, and keep it on 127.0.0.1.
Connect the app
Point the client at the bridge URL and paste the token.
Reach it remotely
Use Tailscale or an HTTPS tunnel. Never expose the port raw.
Start OpenCode
The bridge discovers the local service through
~/.local/state/opencode/service.json. You can also set
OPENCODE_URL and OPENCODE_PASSWORD
explicitly; the URL must be loopback.
opencode service start
Run the bridge
The installer does this for you. Run it by hand when you want to read the config first.
cd bridge
npm ci
cp .env.example .env
openssl rand -hex 32 # put this in AUTH_TOKEN
npm run build
npm start
Set ALLOWED_WORKDIRS to the project roots you want to
expose, then check that the service answers:
The default is ~/projects, not the entire home directory. An existing session outside the configured roots can be explicitly enabled from the app, one session at a time. This is a bridge-level grant, not an OS sandbox: OpenCode tools still run with the filesystem permissions of the OpenCode process.
curl http://127.0.0.1:8787/health
{"ok":true}
Run the app
For a local browser build, allow the Expo origin in
bridge/.env. CORS controls browser reads; it is not
authentication, and the bearer token is still required.
cd app
npm ci
npx expo start
CORS_ORIGINS=http://localhost:8081,http://127.0.0.1:8081
— exact origins only. Wildcards are rejected.
Configuration
| Variable | Default | Description |
|---|---|---|
AUTH_TOKEN |
required | Shared bearer token, at least 32 characters. |
HOST |
127.0.0.1 |
Bind address. Keep it on loopback. |
PORT |
8787 |
Bridge HTTP port. |
ALLOWED_WORKDIRS |
~/projects |
Roots allowed for sessions and uploads. Keep it narrow. |
CORS_ORIGINS |
empty | Exact browser origins allowed to call the bridge. |
MAX_UPLOAD_MB |
25 |
Per-file limit. |
MAX_SESSION_UPLOAD_MB |
1024 |
Cumulative upload cap per session. |
RATE_LIMIT_PER_MINUTE |
180 |
Unauthenticated request budget per IP. |
Remote access
The token is equivalent to shell access. Only expose the bridge through Tailscale, an SSH tunnel, or an authenticated reverse proxy.
The safe default is loopback plus Tailscale. Never bind the bridge
to 0.0.0.0 and expose the port to the internet.
tailscale serve --bg http://127.0.0.1:8787
# then enter this in the app
https://<machine>.<tailnet>.ts.net
An SSH tunnel works too for a quick test from a laptop. Cloudflare Tunnel is possible for a short experiment, but it puts the bridge behind a public address.