美文网首页
用node+http-proxy实现代理

用node+http-proxy实现代理

作者: adtk | 来源:发表于2017-06-28 17:04 被阅读0次
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实现代理

      本文链接:https://www.haomeiwen.com/subject/dsgucxtx.html