Vue跨域

// 在根路径下新建JS文件vue.config.js

内容为

module.exports = {
publicPath: '/',
devServer: {
proxy: {
'/api': {
target: 'http://localhost:3000/web/xlmc',//需要进入的路径
changeOrigin: true,
pathRewrite: {
'^/api': ''//路径中有api重复,过滤掉
}
},
}
}
};
//在基础路径中const LOCAL_BASE_URL = '/api';  定义,只要匹配到/api就进行跨域
未闻花名
原文地址:https://www.cnblogs.com/duokexiao/p/12512040.html