1、npm install http-proxy-middleware,安装npm http-proxy-middleware包
2、在src文件夹里创建setupProxy.js文件,
const {createProxyMiddleware} = require('http-proxy-middleware'); module.exports = function(app) { //app.use(proxy('/api', { target: 'http://localhost:5000/' })); app.use( createProxyMiddleware( '/aliresource', { target: 'https://xxx.com', pathRewrite: {'^/aliresource' : ''}, changeOrigin: true, // target是域名的话,需要这个参数, secure: false, } ) ); app.use( createProxyMiddleware( '/cheerful', { target: 'https://xxx.video', pathRewrite: {'^/cheerful' : ''}, changeOrigin: true, // target是域名的话,需要这个参数, secure: false, } ) ); };