Send requests to another server
Make an app talk to another server without changing the app: your computer in the place of production, for example.
Make the rule
- Right-click a request of the server that you want to replace and choose Send it to another server…
- In Addresses, leave only the host, such as
api.example.com, for all its addresses. To replace a part, write it asapi.example.com/users*. - In Send to, write the other server, such as
http://localhost:8000. - Press Keep the rule.
For an HTTPS server, its domain must be read too.
Where each request goes
The server that you write takes the place of the original one. The path and the query stay:
| The app asks | Send to | It goes to |
|---|---|---|
https://api.example.com/users?page=2 | http://localhost:8000 | http://localhost:8000/users?page=2 |
https://api.example.com/users | https://staging.example.com/v2 | https://staging.example.com/v2/users |
The method, the headers and the body go as the app sent them, except the name of the host. The app does not know that another server answers.
The cookies and tokens of the app go to the other server too. Send them only to a server that you trust.
See that it works
The request keeps its address in the list, with rule next to its path. Choose it and you read Sent to … with the address where it went.
If the other server is not running, the app gets an error 502, and the request says why.
Go back
Turn the rule off in Rules (⌘R on the Mac, Ctrl+R on Windows and Linux). The next request goes to the original server.