1.vue.config.js文件(可以直接复制)
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
devServer: {
// assetsSubDirectory: 'static',
// assetsPublicPath: '/',// 公共路径(必须有的)
proxy: {
//配置跨域
'api': {
target: 'http://192.168.1.168:8080', //这里后台的地址模拟的;应该填写真实的后台接口
changeOrigin: true, //允许跨域
// ws:false,
pathRewrite: {
'^/api': '' //请求的时候使用这个api就可以
},
}
},
open: true,
https: false,
host: 'localhost', // can be overwritten by process.env.HOST
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
}
})