带有模块请求的node.js中的代理身份验证 [英] proxy authentication in node.js with module request
本文介绍了带有模块请求的node.js中的代理身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在我的node.js应用程序中使用模块请求,并且我需要通过身份验证配置代理设置.
I'm trying to use the module request in my node.js app, and I need to configure proxy settings with authentication.
我的设置是这样的:
proxy:{
host:"proxy.foo.com",
port:8080,
user:"proxyuser",
password:"123"
}
发出请求时如何设置代理配置?有人可以给我一个例子吗?谢谢
How can i set my proxy configuration when i make a request? Could someone give me an example? thanks
推荐答案
以下是如何配置的示例( https: //github.com/mikeal/request/issues/894 ):
Here is an example of how to configure (https://github.com/mikeal/request/issues/894):
//...some stuff to get my proxy config (credentials, host and port)
var proxyUrl = "http://" + user + ":" + password + "@" + host + ":" + port;
var proxiedRequest = request.defaults({'proxy': proxyUrl});
proxiedRequest.get("http://foo.bar", function (err, resp, body) {
...
})
这篇关于带有模块请求的node.js中的代理身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文