Files
jackwener__opencli/docs/advanced/remote-chrome.md
AlexYue 31f58ae699 docs: add VitePress documentation site (#112)
- Add VitePress with full navigation, sidebar, i18n (en/zh), local search
- Create 50+ doc pages: guide, adapters (browser + desktop), developer, advanced
- Migrate content from README.md, CONTRIBUTING.md, TESTING.md, CDP.md, CLI-ELECTRON.md
- Migrate all 11 adapter READMEs to structured documentation
- Add new pages: architecture, yaml-adapter guide, ts-adapter guide, ai-workflow
- Add GitHub Actions workflow for deploying to GitHub Pages
- Add Chinese locale pages (getting-started, installation, browser-bridge, etc.)
- Add docs:dev, docs:build, docs:preview npm scripts
2026-03-20 14:11:56 +08:00

1.4 KiB

Remote Chrome

Run OpenCLI on a server or headless environment by connecting to a remote Chrome instance.

Use Cases

  • Running CLI commands on a remote server
  • CI/CD automation with headed browser
  • Shared team browser sessions

Setup

1. Start Chrome on the Remote Machine

# On the remote machine (or your Mac)
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
  --remote-debugging-port=9222

2. SSH Tunnel (If Needed)

If the remote Chrome is on a different machine, create an SSH tunnel:

# On your local machine or server
ssh -L 9222:127.0.0.1:9222 user@remote-host

::: warning Use 127.0.0.1 instead of localhost in the SSH command to avoid IPv6 resolution issues that can cause timeouts. :::

3. Configure OpenCLI

export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:9222"

4. Verify

# Test the connection
curl http://127.0.0.1:9222/json/version

# Run a diagnostic
opencli doctor

CI/CD Integration

For CI/CD environments, use a real Chrome instance with xvfb:

::: v-pre

steps:
  - uses: browser-actions/setup-chrome@latest
    id: setup-chrome
  - run: |
      xvfb-run --auto-servernum \
        ${{ steps.setup-chrome.outputs.chrome-path }} \
        --remote-debugging-port=9222 &

:::

Set the browser executable path: ::: v-pre

env:
  OPENCLI_BROWSER_EXECUTABLE_PATH: ${{ steps.setup-chrome.outputs.chrome-path }}

:::