Skip to content

feat(daemon): add OPENCLI_DAEMON_HOST and OPENCLI_DAEMON_BIND envs#1425

Open
qinglu008 wants to merge 2 commits into
jackwener:mainfrom
qinglu008:feat/daemon-host-bind-env
Open

feat(daemon): add OPENCLI_DAEMON_HOST and OPENCLI_DAEMON_BIND envs#1425
qinglu008 wants to merge 2 commits into
jackwener:mainfrom
qinglu008:feat/daemon-host-bind-env

Conversation

@qinglu008
Copy link
Copy Markdown

Summary

  • add OPENCLI_DAEMON_HOST so the CLI can reach a daemon that is not on 127.0.0.1 (e.g. when calling out from a container to a daemon on the host)
  • add OPENCLI_DAEMON_BIND so the daemon can listen on an interface other than loopback when the operator explicitly opts in
  • add regression tests covering the default and the env override on the client side
  • document both variables in README.md and README.zh-CN.md, with a security note on OPENCLI_DAEMON_BIND (the daemon has no built-in auth)

Why

The daemon URL was a hardcoded http://127.0.0.1:${OPENCLI_DAEMON_PORT} and the listener was hardcoded to 127.0.0.1. This makes it impossible to use OpenCLI from a container that wants to drive Chrome on the host: even when host.docker.internal:19825 is reachable, the CLI still dials 127.0.0.1 inside the container and fails.

Both new env vars default to 127.0.0.1, so all existing deployments are byte-for-byte unchanged.

Verification

  • npx tsc --noEmit — clean
  • npx vitest run --project unit src/browser/daemon-client.test.ts — 13/13 pass, including the two new cases
  • Manual: with OPENCLI_DAEMON_BIND=0.0.0.0 on the host and OPENCLI_DAEMON_HOST=host.docker.internal inside an OrbStack container, opencli twitter trending returns data from the host's logged-in Chrome session
  • The broader unit suite has unrelated failures in this dev env (project requires Node >= 21, my container has Node 20 → undici webidl.util.markAsUncloneable errors); confirmed identical failures on main before any change, so they are pre-existing and unrelated to this PR

qinglu008 added 2 commits May 9, 2026 07:37
Both default to 127.0.0.1, so existing deployments are unaffected.

OPENCLI_DAEMON_HOST tells the CLI which host to dial when reaching the
daemon. The previous hardcoded 127.0.0.1 made it impossible to call a
daemon running on the host from inside a container; setting this to
host.docker.internal (or any reachable address) now works.

OPENCLI_DAEMON_BIND tells the daemon which interface to bind to.
Defaults to loopback so the daemon stays unreachable from the network
unless the operator explicitly opts in. Documented with a security note
because the daemon has no built-in auth.
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