Skip to content

Debugging tools

Map Local

Answer matching requests with a response you write, a local file or a whole folder, without contacting the server. Create one from a captured response.

Map Local answers matching requests from your Mac instead of the server. The response can be one you type into the rule, a file on disk, or a file picked from a folder by the request’s path. The server is never contacted. Use it to work on a screen before its API exists, to test how an app handles odd data, or to serve a local build of a web app’s scripts.

  1. Make the request once in your app so it appears in the traffic list.

  2. Right-click it and choose Tools › Map Local….

    Cloak Proxy creates a rule that matches the request’s method and URL (without the query string), copies the captured response into it, turns Map Local on and opens the rule.

  3. Edit the status code, headers or body under Respond with.

  4. Make the request again. The app gets your response, and the traffic list shows a Map Local badge on it.

A Map Local rule created from a captured response, ready to edit.

  1. Where the response comes from: Inline, File or Directory.
  2. Status code sent to the app.
  3. Add, edit or remove response headers.
  4. The body, with JSON validation, Format and Minify.
A Map Local rule for GET https://api.example.com/v1/users responding inline with status 200, three headers and a pretty-printed JSON body

When you create a rule from a request that has a response, Cloak Proxy fills it in for you:

Field Copied from the captured response
Matcher The request’s method and URL without its query string, with subpaths off. It matches the same path with any query.
Status code The response’s status.
Headers Only headers that change how an app treats a response: Content-Type, Cache-Control, Set-Cookie, Location, Content-Disposition, WWW-Authenticate, Retry-After and every Access-Control-* header. Server and CDN headers are left out.
Body The decompressed body. JSON is pretty-printed. Other text is copied as is.

If the body isn’t text, such as an image, Cloak Proxy saves it to a file in ~/Library/Application Support/CloakProxy/MapLocal/ and sets the rule to File with that path.

Pick a source under Respond with. Every source uses the Status code field (200 by default); the reason phrase next to it updates as you type.

The response is written in the rule.

Field Notes
Status code Any number.
Headers A new rule starts with Content-Type: application/json; charset=utf-8. Click Add for more; click the minus button to remove one.
Body Any text. JSON bodies show Valid JSON with Format and Minify, or Invalid JSON if a body starting with { or [ doesn’t parse.

For File (when you don’t set Content-Type) and Directory, Cloak Proxy uses the file extension:

Extension Content-Type
.json application/json; charset=utf-8
.html, .htm text/html; charset=utf-8
.js, .mjs application/javascript; charset=utf-8
.css text/css; charset=utf-8
.xml application/xml; charset=utf-8
.txt text/plain; charset=utf-8
.png image/png
.jpg, .jpeg image/jpeg
.gif image/gif
.webp image/webp
.svg image/svg+xml
.ico image/x-icon
.woff2 font/woff2
.woff font/woff
.mp4 video/mp4
.pdf application/pdf
.wasm application/wasm
Anything else application/octet-stream
  • Directorysite/
    • index.html served for /static/
    • Directoryjs/
      • app.js served for /static/js/app.js
    • Directorycss/
      • app.css served for /static/css/app.css
  • Cloak Proxy sets Content-Length from the body, so you never need to add it. Any Content-Length header in the rule is ignored.
  • The body is sent exactly as written: it isn’t compressed. Don’t add a Content-Encoding header unless the file really is compressed.
  • Map Local answers before Mock Sets and Map Remote, so a matching Map Local rule wins over both.
  • The response still goes through No Caching, response scripts, the response breakpoint and the download delay of Network Conditions.
  • Map Local matches the request after request scripts and the request breakpoint have run. If a script changes the URL, Map Local sees the new URL.