Advanced
Network Interception
network route intercepts matching requests through CDP's Fetch domain â
no proxy, and no extension permissions. You can mock a fake response, rewrite the outgoing request,
tamper with the real response, or simply block certain traffic. The verbs and fields mirror Playwright's
conventions, so there's almost nothing to learn.
Three modes
Which mode a single network route rule falls into depends on which flags you pass.
They each step in at a different moment:
--body / --status / --header / --content-type: return a fake response directly; the request is short-circuited and never sent.
--method / --set-body / --set-header / --rewrite-url: alter the outgoing request, then let the real response come back.
--edit-status / --edit-header / --replace: the request goes out as usual, then you modify the real response once it returns.
Mock response
Pass flags like --body and the request is fulfilled directly â a fake response returns immediately
and the real network request is never sent. Ideal for producing empty lists, permission states, or isolating
the backend.
# Mock response (fulfill â the request never leaves the browser)
$ chrome-use network route "**/api/users" --body '{"users":[]}' --status 200 --content-type application/json
$ chrome-use network route "**/api/me" --body '{"vip":true}' --header X-From=mock
Rewrite the outgoing request
Pass --method, --set-body, --set-header, or --rewrite-url,
and the request continues with your overrides (continue with overrides), after which the real response
comes back as usual. This is how you inject a test auth header, replace the request body, or route traffic to staging.
# Rewrite the outgoing request (the real response still comes back)
$ chrome-use network route "**/api/save" --method POST --set-header Authorization="Bearer test"
$ chrome-use network route "**/api/save" --set-body '{"x":1}' # replace the request body
$ chrome-use network route "**/v1/*" --rewrite-url https://staging.example.com/v1/thing
Edit the real response
Pass --edit-status, --edit-header, or --replace 'from=>to',
and the request goes out normally; once the real response returns, you tamper with it, and the page sees the
modified version. Perfect for forcing an endpoint into a 503 error state, or swapping one field
in the response without touching the backend.
# Edit the real response (request sent, response returns, then modified)
$ chrome-use network route "**/api/me" --edit-status 503 # override the status code
$ chrome-use network route "**/api/me" --edit-header X-Env=test # add/override a response header
$ chrome-use network route "**/api/me" --replace 'prod=>staging' # substring replace in the real response body (repeatable)
$ chrome-use network route "**/api/me" --set-json data.user.vip=true # structured edit of one JSON field in the response body
--set-json <dot.path>=<value> locates a field in the response body's JSON by a
dot-separated path and creates or overwrites it â nested paths fill in the intermediate objects
automatically. If the body isn't valid JSON, it falls back to a plain string replace,
the same safe behavior as --replace, instead of failing on the parse error.
--header / --set-header / --edit-header / --replace /
--set-json are all repeatable; request/response headers are merged and
layered on top of the originals.
--resource-type xhr,fetch to scope response edits to API calls.
Block and scope by resource type
Use --abort to cut off a request outright. Any rule can be scoped with
--resource-type to limit its reach and avoid catching other traffic by accident.
# Block completely
$ chrome-use network route "**/analytics" --abort
# Scope a rule to certain resource types
$ chrome-use network route "**/*.json" --abort --resource-type xhr,fetch
Observe and record traffic
Before rewriting, see clearly which requests are in flight. network requests lists captured traffic,
and --clear starts recording fresh; network har records the whole session into a standard
HAR file.
$ chrome-use network requests --clear # clear and start capturing again
$ chrome-use network requests # see which requests went out
$ chrome-use network har start # record all traffic
# ... perform your actions ...
$ chrome-use network har stop /tmp/trace.har
Clean up rules
All route rules are persistent and stay in effect until you explicitly remove them. When you're done, use
network unroute to drop them all at once so they don't affect later sessions.
$ chrome-use network unroute # remove all route rules
network unroute,
otherwise a stray --abort can quietly break the next task's page.