vue.config.js文件
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
devServer: {
host: 'localhost',
https: false,
open: false,
port: 8080,
proxy: {
'/api': {
target: '***', //需要访问的地址
pathRewrite: {
"^/api": "/api"
},
changeOrigin:true,
}
}
}
})
页面使用
axios.get('......直接写域名后面的地址')..........