node代理配置

技术 解决方案 demo

Node

2020-05-15 13:16:50

328

作者:黑夜男神

var proxyMiddleWare= require('http-proxy-middleware');
var app = express();
var proxyPath = "http://47.104.208.182:8087";//目标后端服务地址
var proxyOption ={
    target:proxyPath,
    changeOrigoin:true,
    ws: true,
    pathRewrite: { '^/api': '/' }
};
app.use(express.static(__dirname + "public"));
app.use("/api",proxyMiddleWare(proxyOption));
app.listen(4000);//4000是我要启动的端口

评论 (0)

用户名
邮箱
评论

    Copyright © 2020 darkNightMan All Rights Reserved Pro 黔ICP备20005477号