尝试使用协议分析器(Charles)捕获node.js http流量,但无法获取节点使用代理

Chr*_*ris 6 macos https proxy http node.js

我试图用协议分析器(Charles)捕获node.js http流量但是无法让节点使用代理.有没有办法让节点http和https模块使用代理?

我顺便使用OSX

小智 5

谢谢克里斯,在我的例子中,我使用的是查尔斯和请求模块。有一个处理代理选项来放置您的查尔斯端口。

所以要在Charles菜单Proxy->Proxy Settings->Http Proxy中找到你的端口

在任何请求中使用此端口号,例如:

request.get(url, {
  'proxy': 'http://localhost:<charles-proxy-port>'
}, function (error, response, body) {
   //did you see me in Charles??
});
Run Code Online (Sandbox Code Playgroud)


Chr*_*ris 3

弄清楚了。我按照How can I use an http proxy with node.js http.Client? 中的说明进行操作 我认为我需要使用 https 来访问代理。但是如果我使用 http 访问代理,并传递例如“路径:” https://www.google.com/accounts/OAuthGetRequestToken ',那么它就可以工作......