【问题标题】:node-http-proxy not passing post datanode-http-proxy 不传递帖子数据
【发布时间】:2014-07-10 22:04:45
【问题描述】:

服务器监听 localhost:8080

PhantomJS 监听 localhost:8081

代理设置从服务器

发送请求到PhantomJS
var proxy = httpProxy.createProxyServer({ target: 'http://localhost:8081'});
var server = http.createServer(function(req, res) {

    if (req.url === '/phantom') proxy.web(req, res);
    else res.end('yes yes');
});

server.listen(8080);

http://localhost:8080/phantom(服务器代理)的发布请求具有“未定义”的请求。发布

http://localhost:8081/ (PhantomJS) 的发布请求已填充 request.post

我必须做什么才能通过代理接收帖子数据?

【问题讨论】:

    标签: node.js node-http-proxy


    【解决方案1】:

    试试127.0.0.1替换localhost

    【讨论】:

    • 我很想对这个答案投反对票。 127.0.0.1 是链接到 localhost 的 IP 地址。检查您的/etc/hosts 文件或%SystemRoot%\system32\drivers\etc\hosts 文件,它应该显示localhost -> 127.0.0.1 这甚至没有回答问题。
    猜你喜欢
    • 2012-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-16
    相关资源
    最近更新 更多