用node+http-proxy实现代理

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

var proxy = httpProxy.createProxyServer({});

app.all('*',function(req, res){
     res.header("Access-Control-Allow-Origin", "*");//允许跨域
     proxy.web(req, res, { target: '要代理的地址:80' });
})

console.log("listening on port 9000");
app.listen(9000);

你可能感兴趣的:(用node+http-proxy实现代理)