Testing locally with Fiddler

Fiddler is awesome when it comes debugging HTTP on your local machine. It can intercept HTTP requests and responses and has a very powerful IDE that adds a lot of extra advanced features that can help you monitor and troubleshoot your HTTP calls.

However, one thing that is tricky with Fiddler is the fact that for Fiddler to intercept any calls made to a locally running/installed API, you need to use a custom URL => http://ipv4.fiddler/<yourAPIEndpoint>

If you have unit tests or you're trying to debug your code, you have to constantly change your endpoint URLs from the "live/production" i.e http://localhost/<yourApiEndpoint> one to the Fiddler designated one i.e. http://ipv4.fiddler/<yourAPIEndpoint>. Well, today, my dear friends, you are going to find a better way to do this and resolve the URL problem once and for all using this cool trick I'm about to show you. Inside the code responsible for composing the URI for your HTTP calls, you can interrogate the local processes to identify whether Fiddler is running and then respond accordingly. The example below shows you how to do this:

P.S Make sure you follow me on Twitter @christosmatskas for more up-to-date news, articles and tips.


  • Share this post on