跳转到内容

控制端点

代理暴露 /__control,用于以编程方式切换模式。

Terminal window
# Get current state
curl http://localhost:8100/__control
# Switch modes
curl -X POST http://localhost:8100/__control \
-H "Content-Type: application/json" \
-d '{"mode": "record", "id": "my-test-1"}'
interface ControlRequest {
mode?: 'transparent' | 'record' | 'replay'; // required unless cleanup is true
id?: string; // required for record/replay (and for cleanup)
timeout?: number; // auto-reset timeout in ms (default: 120000)
cleanup?: boolean; // when true, clean up the session instead of switching mode
websocket?: WebSocketReplayConfig; // per-session WebSocket replay pacing override
}

在大多数配置中,你不会直接调用它 —— playwrightProxy.before()setProxyMode()(参见 API 参考)会替你发送 POST。当你从 shell、CI 步骤或 AI agent 驱动代理时,再使用 /__control