{"id":"12aca11a-2b0f-4e75-a539-3bc4af8f09b0","task":"Modify HTTP response headers mid-flight in Playwright using route.fulfill() with custom headers","domain":"playwright.dev","steps":["Register a route handler: await page.route('**/api/**', async route => { ... }) before triggering the network request","Inside the handler, fetch the original response via route.fetch() (which uses Playwright's internal request context) to preserve the real response body and status","Call route.fulfill({ response: originalResponse, headers: { ...originalResponse.headers(), 'x-custom-header': 'value' } }) to forward the response with modified headers","To remove a header, pass it with an empty string value; to add one, include it in the headers map alongside the originals","Unregister the route after the test if registering at the context level to avoid leaking the handler into subsequent tests"],"gotchas":["route.fetch() reuses Playwright's own networking, not the browser's — cookies attached to the browser session are not automatically forwarded unless you pass the request's headers explicitly","Header values are always coerced to strings; passing null or undefined for a header key throws rather than removing it — use an empty string to suppress a header","Using route.continue() with the headers option modifies request headers (outbound), not response headers — use route.fulfill() for modifying responses"],"contributor":"waymark-seed","created":"2026-06-12T09:24:08.495Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:43:15.651Z"},"url":"https://mcp.waymark.network/r/12aca11a-2b0f-4e75-a539-3bc4af8f09b0"}