How to stop NodeJS “Request” module changes request when using proxy

后端 未结 4 1992
小鲜肉
小鲜肉 2021-02-19 22:49

Sorry if this comes off as confusing.

I have written a script using the NodeJS request module that runs and performs a function on a website then returns with the data.

4条回答
  •  借酒劲吻你
    2021-02-19 23:18

    According to the proxies documentation of the request module:

    By default, when proxying http traffic, request will simply make a standard proxied http request. This is done by making the url section of the initial line of the request a fully qualified url to the endpoint.

    Instead you can use a http tunnel by setting:

    tunnel : true
    

    in the request module proxy settings.

    It could be that in your case, you are making a standard proxied http request, whereas when using a proxy globally on your system or a chrome extension a http tunnel is created.

    From the documentation:

    Note that, when using a tunneling proxy, the proxy-authorization header and any headers from custom proxyHeaderExclusiveList are never sent to the endpoint server, but only to the proxy server.

提交回复
热议问题