Answer the question
In order to leave comments, you need to log in
How to set proxy for all requests coming from node.js script?
I run the sample.js script from the console. It has 3 libs that make requests for http and tcp. The use of proxy in these libs is not provided. It is possible to rewrite them. But I would like to find a better solution. To be more precise - globally prescribe the use of a proxy in the script. Is there such a possibility, please tell me?
Answer the question
In order to leave comments, you need to log in
There was a similar question on stackoverflow.com
http proxy is set like this:
var http = require("http");
var options = {
host: "proxy",
port: 8080,
path: "http://www.google.com",
headers: {
Host: "www.google.com"
}
};
http.get(options, function(res) {
console.log(res);
res.pipe(process.stdout);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question