用node+http-proxy实现代理
2017-06-28 本文已影响0人
adtk
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);