Add a mock rule
proxy_mock_responseMock HTTP responses by adding rules matched on method and URL, supplying response body inline or from a file, and optionally simulating network delays or bandwidth limits.
Instructions
Add an in-memory mock rule. Matches on HTTP method + URL pattern (glob/substring by default against the full URL; set regex=true for a raw regex). Body is supplied inline or via a fixture file on disk. Provide either 'body' or 'bodyFile', not both. Optionally simulate a slow server: delayMs waits before responding (processing time), bandwidthKbps streams the body at a KB/s rate (slow network / big object from far away).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL pattern. Default is glob/substring matched against the full absolute URL (e.g. 'api.example.com/v1/user' or '*/v1/user'). With regex=true, a raw JS regex source. | |
| body | No | Inline response body (small payloads). | |
| regex | No | Treat 'url' as a raw regex (default false). | |
| method | Yes | HTTP method: GET, POST, PUT, DELETE, PATCH, HEAD, or OPTIONS. | |
| status | No | Response status code (default 200). | |
| delayMs | No | Simulated server processing time: delay in milliseconds before the response starts (e.g. 3000 = 3s before the first byte). | |
| headers | No | Response headers, e.g. { "content-type": "application/json" }. | |
| bodyFile | No | Path to a fixture file whose contents become the response body (large payloads). Must be inside the proxy's allowed directories (default: the folder the proxy was launched from). Add --allowed-dir <path> at launch to permit others. | |
| bandwidthKbps | No | Simulated network bandwidth cap: stream the body at this many KB/s (e.g. 50 = slow-network feel, big objects arrive progressively). |