This is a migrated thread and some comments may be shown as answers.

Fiddler for library that doesn't support proxy

1 Answer 159 Views
Fiddler Classic
This is a migrated thread and some comments may be shown as answers.
венцеслав
Top achievements
Rank 1
венцеслав asked on 17 Apr 2015, 11:07 AM

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

 

1 Answer, 1 is accepted

Sort by
0
Eric Lawrence
Telerik team
answered on 20 Apr 2015, 02:57 PM
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.

 
Tags
Fiddler Classic
Asked by
венцеслав
Top achievements
Rank 1
Answers by
Eric Lawrence
Telerik team
Share this question
or