~/.httpmon/scripts/. Each script is a .js file with YAML frontmatter in comments followed by JavaScript hook functions.
Script format
A script has two parts: a YAML frontmatter block (wrapped in// --- comment delimiters) and one or both hook functions.
Frontmatter fields
Hooks
onRequest(ctx) runs before the request is sent to the server.
onResponse(ctx) runs before the response reaches the client.
Script manager
Press S in the TUI to open the script manager. From there you can toggle, create, and delete scripts.
Scripts are reloaded each time the manager opens. Scripts are tagged with category badges — Script, Map Local, or Breakpoint — based on which APIs they use (
ctx.respondWith() for Map Local, ctx.breakpoint() for Breakpoint).

Examples
All examples below use httpbin.org so you can test them immediately.Modify request headers
Modify request headers
Add custom headers to outgoing requests. The httpbin
/headers endpoint echoes back all received headers, so you can verify the script works.Modify response headers
Modify response headers
Override the status code or headers on a response before it reaches the client.
Block requests
Block requests
Block all requests to slow endpoints. Blocked requests never leave the proxy.
Mock a response
Mock a response
Return a synthetic JSON response without hitting the server. Use
ctx.respondWith() to define the status, body, and headers.Serve a local file
Serve a local file
Serve a file from disk instead of forwarding the request. The
file path is relative to the script directory (~/.httpmon/scripts/).Set a breakpoint
Set a breakpoint
Pause the request flow and open an interactive editor. You can inspect and modify the request before it is sent to the server.
Add an auth header
Add an auth header
Inject a bearer token into requests. The httpbin
/bearer endpoint validates the Authorization header and returns 200 on success or 401 without it.Redirect requests
Redirect requests
Rewrite the URL to redirect a request to a different endpoint. The client sees the response from the new URL.
URL matching
Thematch field accepts an array of glob patterns. Use * as a wildcard for any sequence of characters.
You can specify multiple patterns to match different endpoints with a single script:
Error handling
If a script throws an error, httpmon catches it and continues processing the request normally. The error is tracked and displayed in the script manager next to the script name, so you can spot and fix issues without disrupting traffic.See the Script API reference for the full list of context fields and methods.

