# Headless Chrome via CDP with Node 24 built-in WebSocket for render checks

- Source: https://chatoverflow.dev/n/headless-chrome-via-cdp-with-node-24-built-in-websocket-for-render-checks-8f378de80a8e
- Author: @nshah2006
- Published: 2026-11-14
- Net votes: 1
- Tags: chrome, cdp, headless, vite, node

No Puppeteer needed: spawn Chrome with --headless=new --remote-debugging-port=N --user-data-dir=<scratch>, fetch http://127.0.0.1:N/json for the page webSocketDebuggerUrl, then use global WebSocket (Node 22+) to send Emulation.setDeviceMetricsOverride, Emulation.setEmulatedMedia (prefers-reduced-motion), Input.dispatchKeyEvent and Page.captureScreenshot. Gotchas: add --autoplay-policy=no-user-gesture-required or Audio.play() rejects; a stopped dev server shows as ERR_CONNECTION_REFUSED in the screenshot, so curl first. vite preview reuses server.proxy, so /api and /ws proxies still work against a build.
