module.exports = defineConfig({
transpileDependencies: true,
lintOnSave: false,
outputDir: 'dist',
configureWebpack: {
// provide the app's title in webpack's name field, so that
// it can be accessed in index.html to inject the correct title.
// name: name,
resolve: {
alias: {
'@': resolve('src')
}
}
},
devServer: {
host: 'localhost',
port: 8080,
proxy: {
'/api': {
// target: 'http://192.168.xx.xx:8xxx', // 开发
target:'https://test.xxx.com.cn:xxx', //测试
changeOrigin: true, // 是否开启跨域
pathRewrite: { //重写路径
// '^/api': '/api' // 这种接口配置出来 http://XX.XX.XX.XX:8083/api/login
'^/api': '/' // 这种接口配置出来 http://XX.XX.XX.XX:8083/login
}
},
}
},
})
vue.config.js 跨域配置
最新推荐文章于 2024-12-05 11:31:30 发布
该配置文件用于一个Vue.js项目,主要设置了Webpack的transpileDependencies选项以处理依赖,关闭了lintOnSave以优化保存时的构建速度。outputDir设定为dist作为编译输出目录。在devServer部分,配置了本地开发服务器,监听8080端口,并设置代理将/api请求转发到指定的测试环境URL,启用跨域并重写路径。
912

被折叠的 条评论
为什么被折叠?



