Skip to content
Back to blog

Charles Proxy Map Local vs. Map Remote: Testing App Behavior Against Unbuilt Backend APIs

Prasandeep

Published 9 min readTest Automation
Charles Proxy Map Local vs. Map Remote: Testing App Behavior Against Unbuilt Backend APIs

The screen is done. Product wants empty state, error state, and a list with data in tomorrow’s build. The backend ticket is still in progress. Staging returns 404 for /v1/orders.

You do not need a full mock stack for that gap. Charles Proxy can sit between the app and the network and rewrite the call. Two features do most of the work: Map Local and Map Remote. Teams mix them up constantly. One replaces the response with a file. The other replaces the URL and lets another server answer.

This post is the comparison and the field guide: SSL so maps actually fire, a worked Orders flow, when to pick which rewrite, and how to shut maps down before someone mistakes your laptop for staging. When the real API exists, move lasting expectations into Pact.js or Playwright API tests. Charles is the bridge.

Out of scope: installing Charles from scratch, certificate pinning workarounds for release builds, gRPC or raw WebSocket rewriting, and building a shared mock platform. Those need different tools. This post is Map Local vs Map Remote on ordinary HTTPS JSON the app already sends.

The one decision: file vs other host

AspectMap LocalMap Remote
What Charles changesThe response it returns to the clientThe request URL it fetches
Bytes come fromA file (or folder) on your machineAnother HTTP(S) origin
Remote host required?NoYes
Edit loopChange the file, re-requestChange the stub server or the “To” URL
Best fitUnbuilt endpoint, offline demo, exact error bodiesShared WireMock/Mockoon, staging twin, older API host
Classic failStale file, wrong Content-Type, path typoAuth against wrong env, absolute URLs inside JSON, over-broad host map

Map Local: GET https://api.example.com/v1/orders → Charles returns fixtures/charles/orders/empty.json.

Map Remote: same GET → Charles fetches https://wiremock.company.net/v1/orders (or staging) and returns that response.

They are also not Rewrite (find/replace in headers or body) or Breakpoints (pause and edit live). Use those for small patches. Use Map Local when the whole body (and usually status) should be canned. Use Map Remote when another origin should own the response.

Why unfinished APIs block client testing

Unfinished APIs block client testing at the HTTP edge:

  • The path is not deployed, so empty-state and retry UI never run.
  • Client models expect orders[] while the draft OpenAPI still says data.items.
  • Prod will return 401 on expired tokens; the unfinished service never does.
  • Skeleton loaders and double-tap bugs only appear under latency or 503.
  • Staging still speaks last week’s contract while the build expects this week’s.

A happy-path demo API hides all of that. Maps exist so you can force those conditions without waiting on a deploy.

Before you start: decrypt HTTPS in Charles

You need Charles installed, a debug or non-pinned client build you can proxy, and a machine that can reach the API host name you plan to map. If Charles only shows CONNECT tunnels, Map Local and Map Remote will look broken. Fix proxying first.

  1. Point the system, browser, simulator, or device proxy at Charles (default port 8888), or enable Charles’s OS proxy helpers.
  2. Install and trust the Charles Root Certificate on that client.
  3. Proxy → SSL Proxying Settings: add api.example.com:443 (and any other host that returns the JSON).
  4. Open the screen that should call the API. You need a full request row with a readable URL and response, not CONNECT-only.

Android emulator: proxy host is usually 10.0.2.2, port 8888 (host loopback from the emulator).

iOS Simulator: often inherits the Mac proxy when Charles enables macOS proxying.

Physical device: same Wi-Fi as the Charles machine; proxy IP = that machine’s LAN address; install and trust the cert. Apps that pin certificates or block user CAs need a debug build or network-security exception. Without that, you will never see the JSON.

If a feature flag never fires the call, force the path or aim a debug build at the host name you plan to map. Charles cannot rewrite a request that was never sent.

Stub /v1/orders with Map Local

Running example: Orders home calls GET https://api.example.com/v1/orders?status=open and the backend is missing.

Put fixtures in the repo

clike

fixtures/charles/orders/ empty.json one-page.json unavailable.json

empty.json:

json

{ "orders": [], "page": 1, "hasMore": false }

one-page.json:

json

{ "orders": [ { "id": "ord_1001", "status": "open", "totalCents": 2499, "currency": "USD" } ], "page": 1, "hasMore": false }

unavailable.json (set status 503 on the Map Local entry when Charles allows it; otherwise use the error envelope your client already handles):

json

{ "error": { "code": "SERVICE_UNAVAILABLE", "message": "Orders temporarily unavailable" } }

Commit these next to the ticket or test notes. Disk paths on one laptop do not help the next SDET.

Create the Map Local rule

Tools → Map Local → Enable Map Local → Add…

FieldExample
Protocolhttps
Hostapi.example.com
Port443
Path/v1/orders
Query* or blank (match what your Charles build expects)
Local pathAbsolute path to empty.json

Map the path, not the whole production host. A broad map rewrites docs, CDNs, and random tabs while you “only meant Orders.”

Confirm it worked

  1. Clear the Charles session.
  2. Pull to refresh Orders.
  3. Charles marks the row as Map Local.
  4. Response Content-Type is application/json. If Charles serves application/octet-stream and the client rejects it, set type on the map or add a Rewrite.
  5. UI shows the empty illustration and copy, not a forever spinner or a parse crash in logcat / Xcode.

Point the same rule at one-page.json and refresh again. Same map, new file, no backend.

Force the conditions that matter

ConditionHowWhat you check
Emptyempty.jsonEmpty UI, optional analytics
Dataone-page.jsonRows, currency, no crash
Outageunavailable.json + 503Retry CTA, cache behavior
SlowThrottle or breakpoint delaySkeleton; no double submit
UnauthorizedFixture + 401Login wall or refresh token path

One successful map is not a test plan. Each row above is a separate pass.

Send the same call elsewhere with Map Remote

Use Map Remote when another host already has the answer.

Tools → Map Remote → Enable Map Remote → Add…

Prefer path scope:

FromTo
https://api.example.com/v1/orders*https://wiremock.company.net/v1/orders

Host-wide remap is for short spikes only:

FromTo
https://api.example.com/https://api.staging.example.com/

Watch for Map Remote traps

Auth. The app may still send prod tokens. Staging returns 401. Useful if you meant to test that; confusing if you thought “same as Map Local.”

Links inside the body. Map Remote changes the URL Charles fetches. Absolute image or pagination URLs inside JSON still point at whatever the stub wrote. The list call can “succeed” while thumbnails 404.

TLS. The remapped host must present a certificate the SSL-proxied chain accepts.

Protocol limits. Do not expect Map Remote to stand in for gRPC or raw WebSockets the way it does for HTTPS JSON.

Observe the remapped host in Charles, the status code, and the UI. Same bar as Map Local.

When to pick which

SituationPrefer
Endpoint 404s; no stub URL; you need UI todayMap Local
WireMock / Mockoon / shared tunnel already has the routeMap Remote
Demo offline or on flaky VPNMap Local
Compare this build to last week’s API on stagingMap Remote
Editing JSON every few minutes with designMap Local
Several people need the same stub without sharing disk pathsMap Remote

Default for unbuilt APIs: Map Local. Move to Map Remote when the bytes already live on a host the team trusts.

Grade the session and stop false greens

For each scenario, write down:

  1. Charles: mapped or remapped, method, path, status, Content-Type, size.
  2. UI: banner text, empty vs list, whether cached data stayed.
  3. Side effects: analytics, local DB, whether a write fired when it should not.

If Charles says Map Local but the UI errors, open the body and compare field names to the client model. Most “Charles is broken” reports are schema drift.

Disable Map Local and Map Remote when you finish. A teammate chasing “the bug” with your Thursday fixture still enabled will waste half a day. When the real API ships, re-run the same cases against staging with maps off, keep the fixture files as expected payloads, and add lasting coverage in Pact, Playwright request, or mobile instrumentation. Charles should not be the only place that JSON lives six months later.

Failure modes that burn a day

SSL proxying incomplete. CONNECT only. Maps do nothing. Fix cert and SSL Proxying locations before debugging the map UI.

Path or query mismatch. App calls /v1/orders/ or different casing or an extra query. Copy the path from the session into the rule.

BOM or invalid JSON. Client throws; Charles still shows mapped. Validate the file.

Wrong Content-Type. Bytes look fine; client refuses the type.

Status and body disagree. Happy JSON with 500 (or error JSON with 200) hits the wrong branch. Set them together on purpose.

Over-broad Map Remote. Login still hits prod auth while Orders hits staging. Symptoms look like random 401s.

Maps left on. Document fixture paths in the ticket. Export Charles settings if your team shares them. Treat “disable maps” as part of done.

Close: what to do next

Map Local = response from disk. Map Remote = fetch another URL. For unbuilt backends, start with Map Local fixtures for empty, data, 401, and 5xx/slow. Use Map Remote when a shared stub or staging twin already exists. Prove every case from the Charles row and the UI, then turn maps off and promote fixtures into real API or contract tests.

  1. Decrypted HTTPS for the API host in Charles
  2. Path-scoped Map Local or Map Remote with a clear reason
  3. Fixtures or remote stub for empty, data, auth failure, and outage/slow
  4. Each case checked in UI + Charles status/Content-Type
  5. Maps disabled; fixtures kept for CI-facing tests

Summarize this post

Opens the chat with a prompt copied — paste to start.

Get the next guide in your inbox

Weekly AI testing insights, templates, and tool notes — unsubscribe anytime.