Fiddler for library that doesn't support proxy

2 posts, 0 answers
  1. венцеслав
    венцеслав avatar
    1 posts
    Member since:
    Feb 2014

    Posted 17 Apr 2015 Link to this post

    Hello, 

    I'm using node.js and its library supertest/superagent for testing. The odd thing is that there isn't by default support for proxies.

    I'm thinking of way to view headers in Fiddler. Both client and server are locally to my computer. And I have control of request URL.

    Can you think of solution?  Is it possible for Fiddler to change the port in the request?

    Client -> Fiddler port 8888 -> (change request port to 3000)  -> localhost:3000 server

    Thanks

     

  2. Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 20 Apr 2015 Link to this post

    Many Node.js libraries can be "tricked" into running through a proxy like Fiddler using techniques like this one:

    http://stackoverflow.com/questions/8697344/can-a-proxy-like-fiddler-be-used-with-node-jss-clientrequest

    But yes, Fiddler can also act as a "reverse proxy" whereby it pretends to be the origin server and, when it receives a request sent directly to its port, it forwards that request to another port.

    In Fiddler, click Rules > Customize Rules.
     
    Inside the OnBeforeRequest handler, add a new line of code:

    if (oSession.host.toLowerCase() == "localhost:8888") oSession.host = "localhost:80";
     

    Then, update your client's URL from http://localhost/whatever to http://localhost:8888/whatever.

    Don't forget to change the URL back when you're done debugging.

    Regards,
    Eric Lawrence
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top