@ohah/chrome-remote-devtools-server
v0.1.0-rc.1
Published
Chrome Remote DevTools WebSocket relay server with SSL support.
Readme
@ohah/chrome-remote-devtools-server
Chrome Remote DevTools WebSocket relay server with SSL support.
Installation
npm install @ohah/chrome-remote-devtools-serverUsage
Basic Usage
npx chrome-remote-devtools-serverWith Environment Variables
PORT=8080 npx chrome-remote-devtools-serverWith SSL (HTTPS/WSS)
For production, you'll need to set up SSL certificates. You can either:
- Use a reverse proxy (Nginx/Caddy) - Recommended
- Use Bun's built-in HTTPS support
Using CLI Options
npx chrome-remote-devtools-server \
--ssl \
--cert /path/to/cert.pem \
--key /path/to/key.pemUsing Environment Variables
USE_SSL=true \
SSL_CERT_PATH=/path/to/cert.pem \
SSL_KEY_PATH=/path/to/key.pem \
npx chrome-remote-devtools-serverWith Logging
Enable All Logs
npx chrome-remote-devtools-server --log-enabledFilter Logs by Methods
npx chrome-remote-devtools-server \
--log-enabled \
--log-methods "Runtime.evaluate,Page.navigate"File Logging
npx chrome-remote-devtools-server \
--log-enabled \
--log-file ./logs/server.logEnvironment Variables
Basic Configuration
PORT- Server port (default:8080for HTTP,8443for HTTPS)HOST- Server host (default:0.0.0.0)
SSL Configuration
USE_SSL- Enable HTTPS/WSS (default:false)SSL_CERT_PATH- Path to SSL certificate file (required whenUSE_SSL=true)SSL_KEY_PATH- Path to SSL private key file (required whenUSE_SSL=true)
Logging Configuration
LOG_ENABLED- Enable logging (default:false)LOG_METHODS- Comma-separated list of CDP methods to log (default: all methods)LOG_FILE_PATH- Path to log file (logs will be written to both console and file)
CLI Options
-p, --port <number>- Server port-h, --host <string>- Server host--ssl- Enable HTTPS/WSS--cert <path>- Path to SSL certificate file--key <path>- Path to SSL private key file--log-enabled- Enable logging--log-methods <methods>- Comma-separated list of CDP methods to log--log-file <path>- Path to log file--help- Show help message
Note: CLI options take precedence over environment variables.
SSL Certificate Setup
Using Let's Encrypt (Recommended)
# Install certbot
sudo apt-get install certbot
# Get certificate
sudo certbot certonly --standalone -d your-domain.com
# Use the certificate
USE_SSL=true \
SSL_CERT_PATH=/etc/letsencrypt/live/your-domain.com/fullchain.pem \
SSL_KEY_PATH=/etc/letsencrypt/live/your-domain.com/privkey.pem \
npx chrome-remote-devtools-serverUsing Self-Signed Certificate (Development Only)
# Generate self-signed certificate
openssl req -x509 -newkey rsa:4096 -nodes \
-keyout key.pem \
-out cert.pem \
-days 365 \
-subj "/CN=localhost"
# Use the certificate
npx chrome-remote-devtools-server \
--ssl \
--cert ./cert.pem \
--key ./key.pemWarning: Self-signed certificates are not secure for production use. Use Let's Encrypt or a trusted CA for production.
Examples
Development Server
# HTTP on default port
npx chrome-remote-devtools-server
# HTTP on custom port
npx chrome-remote-devtools-server --port 3000
# With logging
npx chrome-remote-devtools-server --log-enabledProduction Server
# HTTPS with Let's Encrypt
USE_SSL=true \
SSL_CERT_PATH=/etc/letsencrypt/live/your-domain.com/fullchain.pem \
SSL_KEY_PATH=/etc/letsencrypt/live/your-domain.com/privkey.pem \
LOG_ENABLED=true \
LOG_FILE_PATH=/var/log/chrome-remote-devtools/server.log \
npx chrome-remote-devtools-serverAPI
The server provides the following HTTP endpoints:
GET /json- Get all clientsGET /json/clients- Get all clients with detailsGET /json/inspectors- Get all inspectorsGET /json/client/:id- Get specific client
WebSocket endpoints:
WS /remote/debug/client/:id- Client connectionWS /remote/debug/devtools/:id- DevTools connection
License
MIT
