const { createProxyMiddleware } = require('http-proxy-middleware'); module.exports = (app) => { app.use( createProxyMiddleware('/api', { target: '192.168.1.xx:xxxxx', //目标服务器 changeOrigin: true, //是否需要修改原始主机头为目标URL,默认为False pathRewrite:{ '^/api': "web/", //重写请求 }, https: false, secure: false, }) ); };
本文作者为MingJun,转载请注明。