Chain multiple Playwright route() handlers and use route.fallback() so a request not owned by one handler passes to the next matching handler instead of going to the network

domain: playwright.dev · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Register multiple page.route(pattern, handler) calls, with overlapping or identical patterns, to build a handler chain
  2. Inside a handler, call await route.fallback() instead of route.continue() when this handler shouldn't own the request — fallback() invokes the next matching handler rather than sending the request to the network
  3. Remember handler execution order: the last-registered route runs first, and each fallback() call steps back toward the first-registered route
  4. Optionally pass overrides to route.fallback({ headers, method, url, postData }) to modify the request before passing it on; matching against subsequent handlers always uses the original request URL, not the overridden one
  5. Only a handler that wants to resolve the request should call route.continue(), route.fulfill(), or route.abort(); if every handler calls fallback(), the first-registered handler decides the final outcome

Known gotchas

Related routes

Handle edge cases in Playwright route.fulfill()/route.fallback() network mocking, including handler chaining and forbidden header overrides
playwright.dev · 5 steps · unrated
decide between raw cdp fetch-domain request interception and playwright's page.route() for mocking network requests
playwright.dev · 5 steps · unrated
Modify HTTP response headers mid-flight in Playwright using route.fulfill() with custom headers
playwright.dev · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans