Use node-XMLHttpRequest through a Proxy?

前端 未结 2 997
野趣味
野趣味 2020-12-12 05:15

I need to deploy my node-XMLHttpRequest app to a server that uses a proxy to access the internet. In a terminal on that server, I can curl -d \"\" http://website/path<

相关标签:
2条回答
  • 2020-12-12 05:23

    This fork adds a config object that can specify a proxy to use.

    https://github.com/jbeuckm/node-XMLHttpRequest

    0 讨论(0)
  • 2020-12-12 05:36

    Did you provide the proxy options to the http connection?

    The below should help.

    var http = require("http");
    
    var options = {
    hostname: "<proxy-server-address>",
    port: <proxy-server-port>,
    path: "http://www.xyz.com",
    headers: {
      Host: "www.xyz.com"
             }
    };
    
    var req = http.request(options, function(res){ ... });
    
    req.end();
    
    0 讨论(0)
提交回复
热议问题