~/.httpmon/scripts/. Each script has YAML frontmatter inside JS comments and exports onRequest and/or onResponse hooks.
Script file format
// --- lines. Each YAML line is prefixed with // .
Frontmatter fields
onRequest(ctx)
Runs before the request is sent upstream.onResponse(ctx)
Runs before the response reaches the client.ctx.respondWith(options)
Short-circuits the normal proxy flow and returns a synthetic response. Available in bothonRequest and onResponse.
In onRequest, calling respondWith stops script execution immediately. The request is never sent upstream. In onResponse, execution continues after the call.
When you use
file, the content-type is auto-detected from the file extension. The file and body options are mutually exclusive.
ctx.breakpoint()
Pauses the flow for interactive editing in the TUI. You can inspect and modify headers and body before the flow continues.ctx.readFile(path)
Reads a file from disk and returns its contents as a string. Returnsnull if the file does not exist. Paths are resolved relative to the script’s directory.
URL match patterns
Match patterns use glob syntax with* wildcards. The format is scheme://host/path.
*in the scheme position matches any scheme (http or https).*in the host matches a single domain label (*.example.commatchesapi.example.combut nota.b.example.com).*in the path matches any substring including slashes.

