Xcode Charles (HTTP Proxy) does not commit localhost traffic

I am trying to test http traffic (non-SSL) using Xcode 6.1 and iOS Simulator 8.1 using Charles and my apache localhost server.

Charles works correctly for me, but it only captures traffic when I use my LAN IP: 192.168.1.X as the target host for requests in iOS.

I tried other suggestions from Charles's article here , but no one works except the LAN IP.

β€œWhy not just use the IP address of the LAN?” You ask ?. Well, I would like to avoid YASCE (another exception for source control). You see, my source code has this in the network section:

 #if DEBUG var API_HOST = "http://localhost" #else var API_HOST = "https://website.com" #endif 

I would not want every developer in the team to constantly make special comments so as not to check their own IP address every time they take control of the source.

Is there any other way I can convince the iOS simulator to pass http://localhost through Charles, or is there a better way to handle the environment settings with the development team?

+7
ios xcode proxy configuration charles
source share
4 answers

Use localhost.charlesproxy.com instead of localhost . This DNS setting charlesproxy.com points to 127.0.0.1 and will always be. And since it is not literally localhost , it must bypass the OS logic for localhost .

It is also possible to use local.charles , but only if Charles actually works, and you use it as your proxy. Therefore, I prefer the solution localhost.charlesproxy.com .

I will also update the FAQ.

+4
source

I found an acceptable job. It includes editing your hosts file to create an alias for localhost. Each developer will have to do this on his machine, but after that it should be smooth.

Run echo '127.0.0.1 local.website.com' >> "/etc/hosts" and then change the host configuration code to something like this:

 #if DEBUG var API_HOST = "http://local.website.com" #else var API_HOST = "https://website.com" #endif 
+2
source

I use my hostname instead of localhost. To get the host name, just enter hostname in the terminal and then change the url to "http://your-host-name"

+1
source

The same thing happened to me. Using my computer name instead of "localhost" solved my problem and allowed me to map it to Charles. For example, my computer name is "sukwon", and I decided to use it " http: //sukwon.local instead of using" http: // localhost "

0
source

All Articles