Rewrite
Add, remove or replace headers and query parameters, change the method, host, path or status, or replace a body on matching traffic.
Rewrite changes real traffic on its way through. Unlike Map Local, the request still reaches the server; WireLens edits what goes out, what comes back, or both.
Create a rule#
Open Tools ▸ Rewrite and add a rule, or select a flow and choose Create Rewrite Rule… (⇧⌘R on the Mac), which starts from that flow's URL.
What a rule can change#
| Side | Changes |
|---|---|
| Request | Set or remove headers · set or remove query parameters · change the method · change the host · change the path · replace the body |
| Response | Change the status · set or remove headers · replace the body |
A body replacement swaps the whole body for the text you give it. When WireLens replaces a body that arrived compressed, it also fixes the framing headers, removing Content-Encoding and setting Content-Length, so the app parses the new body correctly.
To change one field inside a JSON body rather than the whole thing, use Scripting: res.body.json(), edit the value, write it back.
Matching#
- URL pattern. Wildcards or a regular expression. A blank pattern is refused, because it would match every request.
- Scope. Narrow a rule further by method, response status class, content type, a header or a GraphQL operation name, so a rule for
POSTerrors leaves successful calls alone. - Test this rule checks the pattern against sample URLs before you save it.
For HTTPS, the host must be decrypted, since WireLens can only change what it can read. A rule aimed at a host that is not on the SSL Proxying Include list says so in the Tools pane.
Rewrite, Map Remote or Scripting?#
- Change the destination of a request: Map Remote.
- Change fixed parts of a request or response: Rewrite.
- Change something that depends on the request itself, or edit a single JSON field: Scripting.
Settings exports#
Rewrite rules often carry tokens in a header value or a body. When you export your settings, WireLens redacts secrets inside rule bodies as well as headers unless you explicitly include them.
Free and Pro#
The free plan includes one Rewrite rule. Pro removes the limit.
From the command line#
wirelens rules rewrite takes one flag per change and can be repeated:
wirelens rules rewrite --pattern 'https://api.example.com/*' \
--set-header 'X-Debug: 1' \
--remove-header Cookie \
--status 503 \
--response-body '{"error":"maintenance"}' \
--note 'Maintenance drill'
Run wirelens help for the full flag list, including --set-query, --remove-query and --request-body. The MCP tool is add_rewrite.
Something here is unclear, or wrong for your setup? Contact support or write to support@wirelens.app.