通过代理使用 node-XMLHttpRequest? [英] Use node-XMLHttpRequest through a Proxy?

查看:19
本文介绍了通过代理使用 node-XMLHttpRequest?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将我的 node-XMLHttpRequest 应用部署到使用代理访问的服务器互联网.在该服务器上的终端中,我可以 curl -d "" http://website/path 并且它工作正常.我认为 curl 在这种情况下可以识别环境变量 http_proxy.节点应用程序超时,因为它没有看到代理.如何让节点应用使用代理?

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 and it works fine. I think curl recognizes the environment variable http_proxy in that case. The node app times out because it doesn't see the proxy. How can I get the node app to use the proxy?

例如,我可以使用 http.globalAgent 通过代理发送请求吗??

For instance, could I use http.globalAgent to send the requests through the proxy?

推荐答案

这个 fork 添加了一个配置对象,可以指定要使用的代理.

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

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

这篇关于通过代理使用 node-XMLHttpRequest?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆