storm_BI_screen/vue.config.js
2025-10-02 17:23:13 +08:00

44 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const { defineConfig } = require('@vue/cli-service')
const path = require('path')
const resolve = dir => {
return path.join(__dirname, dir)
}
module.exports = defineConfig({
publicPath: './',
transpileDependencies: [],
chainWebpack: config => {
config.resolve.alias
.set('_c', resolve('src/components'))
},
// 修正 devServer 配置
devServer: {
port: 81,
host: 'localhost',
open: true,
// 添加禁用主机检查,避免 Invalid Host header 错误
allowedHosts: 'all',
// 添加更严格的代理配置
proxy: {
'/dev-api': {
target: 'http://localhost:8080', // 后端在8080端口
changeOrigin: true,
secure: false, // 如果后端是http需要这个
logLevel: 'debug', // 可以查看代理日志
pathRewrite: {
'^/dev-api': '' // 移除 /dev-api 前缀,直接转发到后端根路径
},
// 添加headers确保正确传递
headers: {
Connection: 'keep-alive'
}
}
}
},
outputDir: 'dist',
assetsDir: 'static'
})