Modify request and response headers
New in 1.2
A Modify headers rule sets or removes headers on matching requests. It runs in Chrome’s network stack, so it applies to every kind of request: fetch and XHR, scripts, CSS, images, frames and page loads.
Header changes
Each rule has one or more changes:
- Request or Response: request headers are changed before the request leaves the browser; response headers before the page sees them.
- Set a header to a value (it’s added if it’s missing), or Remove it.
Examples
Requests to your API
| You want | Changes |
|---|---|
| Send a debug or feature-flag header to your API | Request · Set · X-Debug = 1 |
| Try an API with another token | Request · Set · Authorization = Bearer test-token |
| Act as another user or tenant on a test backend | Request · Set · X-Tenant-Id = acme |
| Send requests without your login, to see the signed-out errors | Request · Remove · Cookie and Request · Remove · Authorization |
| Send one fixed cookie (it replaces all the cookies of that request) | Request · Set · Cookie = session=test123 |
| Get answers in another language | Request · Set · Accept-Language = de-DE |
| Bypass caches on the way to the server | Request · Set · Cache-Control = no-cache |
Send another Referer |
Request · Set · Referer = https://partner.example.com/ |
What the server thinks your browser is
| You want | Changes |
|---|---|
| Get the mobile version of a site | Request · Set · User-Agent = a mobile user agent |
| Hide your client hints | Request · Remove · Sec-CH-UA, Sec-CH-UA-Mobile and Sec-CH-UA-Platform |
This changes what the server receives. The page’s own navigator.userAgent stays the same.
Responses
| You want | Changes |
|---|---|
| Load a page without its Content Security Policy while developing | Response · Remove · Content-Security-Policy |
| Embed a page in an iframe on your site | Response · Remove · X-Frame-Options and Response · Remove · Content-Security-Policy |
| Allow your local front end to call an API | Response · Set · Access-Control-Allow-Origin = http://localhost:5173 |
| The same, with cookies | Add Response · Set · Access-Control-Allow-Credentials = true (the origin can’t be * then) |
| See how the app copes without caching | Response · Set · Cache-Control = no-store |
| Open a file in the tab instead of downloading it | Response · Remove · Content-Disposition |
| Show a JSON or CSV file as plain text | Response · Set · Content-Type = text/plain |
| Test a feature flag your server sends in a header | Response · Set · X-Feature-New-Checkout = on |
Together with a mock
A mocked response gets the headers of matching header rules too. For example, to test pagination that reads the total from a header:
- An Override response rule for
/api/itemsthat returns a page of items. - A Modify headers rule for the same pattern: Response · Set ·
X-Total-Count=250, and Response · Set ·Link=<https://api.example.com/items?page=2>; rel="next".
Only some requests
The URL pattern and method filter decide which requests a header rule changes:
- Pattern
api.example.comchanges only your API, not the page, its scripts or other sites. - Method
POSTwith Request · Set ·X-Idempotency-Key=test-1checks how your server handles a repeated key. - A regex pattern such as
^https://[^/]+\.staging\.example\.com/covers every staging subdomain.
How header rules combine with other rules
- Header rules don’t take part in “first match wins”: every matching header rule applies, together with whatever override, block or redirect rule handles the request.
- When two header rules change the same header, the one higher in the list wins.
- A mocked response never reaches the network, so Placebo API applies the response-header changes to it itself.
Good to know
- Removing security headers such as
Content-Security-Policyis for development and testing only. Keep those rules switched off when you don’t need them. - Changes don’t show in DevTools for every request type. To check a response header, read it in the page (for example
response.headers.get("x-test")).
Something unclear or missing? Tell me, and I'll fix the docs.