在vue项目根目录下创建文件vue.config.js
module.exports = {
pages: {
index: {
//入口
entry: 'src/main.js',
},
},
lintOnSave:false, //关闭语法检查
//开启代理服务器(方式一)
//当本地路径没有才请求网址的,如当文件夹public里有student文件,就会获得该文件内容
devServer: {
proxy: 'http://localhost:3000'//要跨域访问的端口号
}
//开启代理服务器(方式二)
// devServer: {
// proxy: {
// '/atguigu': {
// target: 'http://localhost:5000',
// //请求的资源所在网址没有前缀/atguigu,去掉
// pathRewrite:{'^/atguigu':''},
// // ws: true, //用于支持websocket
// // changeOrigin: true //用于控制请求头中的host值,true说真话,端口号是8080,false说假话,端口号也是5000
// },
// '/demo': {
// target: 'http://localhost:5001',
// pathRewrite:{'^/demo':''},
// // ws: true, //用于支持websocket
// // changeOrigin: true //用于控制请求头中的host值
// }
// }
// }
}