var express = require('express');
var proxy = require('http-proxy-middleware');
var app = express();
app.use('/', proxy({ target: 'https://www.baidu.com/', changeOrigin: true }));
app.listen(3000);
访问 http://localhost:3000/ 就相当于访问百度了。
var express = require('express');
var proxy = require('http-proxy-middleware');
var app = express();
app.use('/', proxy({ target: 'https://www.baidu.com/', changeOrigin: true }));
app.listen(3000);
访问 http://localhost:3000/ 就相当于访问百度了。