Node-HTTP-Proxy错误

时间:2016-07-12 03:07:26

标签: javascript node.js express twitter proxy

我正在尝试使用我的简单twitter tweeter首次实现节点http代理。我之前从未使用过这个,并试着跟着文档(https://github.com/nodejitsu/node-http-proxy)没有运气。谁能指出我正确的方向?另外,可以在Mac上本地运行吗?谢谢

var express = require('express');
var app = express();
var port = 8300;
var twitter = require('twitter');
var twit = new twitter({  keys and stuff })


var http = require('http'),
httpProxy = require('http-proxy');


twit.post('statuses/update', {status: "Hello world!"}
//this works



httpProxy.createProxyServer({target:'http://localhost:3000'}).listen(3000); 



// Create your target server--- WHat exactly does this mean??

http.createServer(function (req, res) {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));

  res.end();
}).listen(3000);

1 个答案:

答案 0 :(得分:0)

您不应该使用此lib来代理您的请求。这个lib用于制作您自己的代理服务器。请查看example如何使用twitter lib

代理
相关问题