2 min read
How to connect an App to BFC API running locally
During feature development and bug fixing there are situations when you need to connect an App running on your device to an API running locally. How to do that for an IOS device is described in this section.
- Have Charles Proxy installed on your computer
- Have Application installed on your phone (in this tutorial we will be using IOS device)
- Have BFC API running on your computer
- Launch Charles
- Select Help > SSL Proxying > Install Charles Root Certificate on a Mobile Device or Remote Browser
You will be presented with the following window:
- On your iPhone, open Settings > Wi-Fi > PoqCommerce WiFi > Configure Proxy. On this page set following values and press Save:
- In Server, type the IP address displayed by Charles on your Computer (final screen from point 2)
- In Port, type the port displayed by Charles on your Mac (final screen from point 2)
- Leave Authentication off
- On your iPhone, open Safari and go to https://chls.pro/ssl. Hit Allow and install the root certificate
- Open Settings > General > About > Certificate Trust Settings. Switch Charles certificate to On.
- Open an app on your iPhone.
- Check Charles logs on your Computer. You should now see traffic coming from your device in Charles.
- At the moment traffic is being routed to standard domain and standard route https://dev.poq.io/clients/yourbrand, while we need it to be routed to https://localhost:5001. In order to change that go to Charles on your Computer and open Tools -> Rewrite window
- In Rewrite Settings click Add button to add new rewrite rule and set the name of the rule
- In Location tab, press Add button specify following values:
- Protocol: https
- Host: dev.poq.io
- On Type and Action tab, press Add button and specify following values:
- Type: URL
- Match.Value: https://dev.poq.io/clients/yourbrand
- Match.Match whole value: unchecked
- Match.Case sensitive: unchecked
- Replace.Value: https://localhost:5001
- Replace.Replace First: selected
- Check Charles logs again, you should now have all the traffic redirected to the API running locally
Congratulations! You have successfully linked an Application on your device with the API running locally.