http-proxy-middleware 是一套 Node.js 代理中间件 for conNECt, Express 和 browser-sync。
安装
$ npm install --save-dev http-proxy-middleware
配置
var proxyMiddleware = require('http-proxy-middleware'); var proxy = proxyMiddleware('/api', {target: 'http://www.example.org'}); // \____/ \________________________________/ // | | // context options // 'proxy' is now ready to be used in a server.