Search code examples
node.jsproxyfiddlerhttp-proxy-middleware

Specifying proxy for http-proxy-middleware


I have a nodeJS project for a front-end that connects to multiple micro services.When we do final deployments we actually deploy the built JS and HTML in a WAR file along with the backend.

However, for development we use the http-proxy-middleware so we are able to do quick changes and edits on the front-end and see the results.

Today though, I would like to be able to see the connections leaving NODE-JS and going towards our microservices.

Specifically, I want to tunnel them through fiddler ( which is an http proxy usually running on port 8888 ).

Does anyone know to do this?

I tried setting e.g. the following but it doesn't affect the outgoing connection:

npm config set proxy http://localhost:8888


Solution

  • Well, the answer to my problem is to use fiddler as a reverse proxy:

    https://docs.telerik.com/fiddler/Configure-Fiddler/Tasks/UseFiddlerAsReverseProxy

    I came across it by accident partly. I thought maybe I can't intercept all requests, but I could set my endpoint as being fiddler.

    I did that, and saw a response in fiddler from the Fiddler Echo Service.

    It basically displays a page similar to:

    Fiddler Echo Service
    
    PUT /abc-service/initialize HTTP/1.1
    accept-language: en-AU,en;q=0.9,el;q=0.8,en-NZ;q=0.7,en-US;q=0.6,en-GB;q=0.5
    accept-encoding: gzip, deflate, br
    accept: */*
    postman-token: 0466cca5-21f9-67ab-be05-5227ef667fe4
    user-agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36
    origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop
    cache-control: no-cache
    content-length: 0
    connection: close
    host: localhost:8889   
    X-Tenant-Id: abc  
    X-Forwarded-Proto: http
    X-Forwarded-Force-Http-Protocol: true
    X-Forwarded-Prefix: abc-service
    
    This page returned a HTTP/200 response 
    Originating Process Information: node:15044
    
    --------------------------------------------------------------------------------
    •To configure Fiddler as a reverse proxy instead of seeing this page, see Reverse Proxy Setup ( https://docs.telerik.com/fiddler/Configure-Fiddler/Tasks/UseFiddlerAsReverseProxy )
    •You can download the FiddlerRoot certificate