Skip to content
subcloakdocs

Debugging tools

Map Remote

Send matching requests to a different scheme, host, port, path or query, such as staging or a local dev server, with a live preview of the rewritten URL.

Map Remote sends matching requests to a different server. You choose which parts of the URL to change (scheme, host, port, path or query) and leave the rest as the app sent it. Use it to point a production build at staging, send one API version to a local dev server while keeping the rest of each path, or compare two versions of an API without rebuilding anything.

  1. Right-click a request from the server you want to replace and choose Tools › Map Remote….

    Cloak Proxy creates a rule that matches the request’s URL (without its query string) for any method, with subpaths on, and fills Host with the current host. It turns Map Remote on and opens the rule.

  2. Change the matcher if you want more of the API mapped. For a whole host, use https://api.example.com/.

  3. Under Send to, fill in only the parts that should change. For staging, change Host to staging.example.com. Since 0.5.1 To send everything under the pattern to a local server, type http://localhost:8080/* in Fill in from a URL and press Return: it fills in the scheme, host and port, and the trailing * sets Path to Swap the prefix.

  4. Check the Preview line, or type a URL in the tester under the pattern (see Test a rule), then make the request again. The traffic list shows the new URL with a Map Remote badge.

Swap the prefix keeps the rest of the path and the query. The tester shows where a URL goes.

  1. Test a URL, or pick a captured request
  2. Redirect the request, or send a copy and compare
  3. Fill in the fields from a destination URL
  4. Host to send requests to
  5. Path: replace it, or swap the prefix
  6. Preview: the original URL struck through, and the rewritten one
A Map Remote rule matching https://api.shopapp.example/v1/* with scheme http, host localhost, port 8080 and Path set to Swap the prefix with /, and the tester showing https://api.shopapp.example/v1/orders/ord_1001?expand=items matches and becomes http://localhost:8080/orders/ord_1001?expand=items

Every field is optional. An empty field keeps that part of the original URL, as its placeholder says (unchanged).

Field Example What it does
Fill in from a URL Since 0.5.1 http://localhost:8080/* Fills in the fields below from a destination URL. A trailing * sets Path to Swap the prefix; without one, Path replaces the whole path. A URL without a scheme keeps the current Scheme.
Scheme http Switches between http and https. Entered in any case; sent in lowercase.
Host staging.example.com The server to connect to. A port after a colon (localhost:3000) is used when Port is empty. Since 0.5.1
Port 3000 A port number. When it’s the default for the scheme (443 for HTTPS, 80 for HTTP) it’s left out of the URL.
Path: Replace the path /v2/users Replaces the whole path. A missing leading / is added.
Path: Swap the prefix Since 0.5.1 / or /v2/ Replaces only the start of the path that the rule’s pattern spells out (/v1/ for https://api.example.com/v1/*) and keeps the rest and the query. Empty means /.
Query debug=1 Replaces the whole query string. A leading ? is optional.
Keep the original Host header Off When off, the Host header is set to the new host (and port, if it isn’t the default). When on, the app’s original Host header is sent to the new server.

For the request https://api.example.com/v1/users?page=2:

You set The request goes to
Host staging.example.com https://staging.example.com/v1/users?page=2
Scheme http, Host localhost, Port 3000 http://localhost:3000/v1/users?page=2
Path /v2/users https://api.example.com/v2/users?page=2
Query debug=1 https://api.example.com/v1/users?debug=1
Path /v2/, Swap the prefix (rule api.example.com/v1/*) https://api.example.com/v2/users?page=2
Scheme http, Host localhost, Port 8080, Path /, Swap the prefix http://localhost:8080/users?page=2
Since 0.5.1

With Path set to Swap the prefix, the part of the path the pattern spells out before its first * is swapped for Path, and the rest of the path and the query are kept. For a rule matching https://api.example.com/v1/*:

Request Path / Path /v2
/v1/users?page=2 /users?page=2 /v2/users?page=2
/v1/users/42/orders /users/42/orders /v2/users/42/orders
/v1/ and /v1 / /v2/ and /v2

The prefix is compared without regard to case, like the pattern. A pattern whose prefix doesn’t end in / (api.example.com/v1*) swaps text: /v1beta/x with Path /v2 becomes /v2beta/x. A wildcard in the host (*.example.com/static/*) doesn’t change the prefix. With a regular expression, there’s no literal prefix, so the whole path is kept after Path: /proxy sends /users to /proxy/users.

With Replace the path, Path replaces the entire path: a rule matching api.example.com/v1/* with Path /v2/users sends every /v1/… request to /v2/users. Up to 0.5.0, that was the only choice.

Below the fields, Preview shows an example URL built from your matcher (each * replaced by example, and https:// added when the pattern has no scheme), struck through, and under it the URL Map Remote would send. It updates as you type.

Since 0.5.1

Type a URL in the tester under the pattern, or pick a captured request from Captured, to see whether the rule matches it and, for Map Remote, the URL it’s sent to. See Test a pattern.

Since 0.4.0

Under When a request matches, Send it there instead (the default) redirects the request. Send a copy there and compare leaves the request alone — it goes to its own host as usual — and, once it has finished, sends a copy to the rule’s destination and compares the two answers in Compare Environments. Use it to check that staging answers like production while you use the app. Writes aren’t copied unless you allow them there, and copies are rate-limited.

Most servers need a Host header that matches their own name, so leave Keep the original Host header off. Turn it on when the new server routes by the original name, for example:

  • A load balancer or reverse proxy at an IP address that serves several sites.
  • A local server that expects the production host name.

To keep the URL and Host header and only change which machine you connect to, DNS Spoofing is often simpler.

  • Map Remote matches the request after request scripts and the request breakpoint, and runs after Map Local and Mock Sets. If either answers the request, Map Remote doesn’t run.
  • Only the first matching Map Remote rule is used.
  • URLs that contain characters such as |, { or spaces in the query are mapped like any other; their path and query are sent as the app wrote them. Since 0.5.1
  • DNS Spoofing and No Caching apply to the rewritten request.
  • Response scripts and the response breakpoint still match the original URL. Alerts match the rewritten URL, which is also what the traffic list shows.