2025-03-12 13:38:44 +08:00
|
|
|
const { defineConfig } = require('@vue/cli-service');
|
|
|
|
|
const dotenv = require('dotenv');
|
|
|
|
|
|
2025-03-12 23:31:59 +08:00
|
|
|
// 确保加载 .env 文件
|
2025-03-12 13:38:44 +08:00
|
|
|
dotenv.config();
|
|
|
|
|
|
|
|
|
|
module.exports = defineConfig({
|
|
|
|
|
devServer: {
|
|
|
|
|
// Bug 修复:将代理配置为环境变量中定义的 API 基础 URL
|
2025-03-21 16:42:00 +08:00
|
|
|
port: 8001, // 指定端口为 8001
|
2025-03-12 23:31:59 +08:00
|
|
|
proxy: {
|
|
|
|
|
'/xiaozhi-esp32-api': {
|
|
|
|
|
target: process.env.VUE_APP_API_BASE_URL || 'http://localhost:8002', // 后端 API 的基础 URL
|
|
|
|
|
changeOrigin: true, // 允许跨域
|
|
|
|
|
// pathRewrite: {
|
|
|
|
|
// '^/api': '', // 路径重写
|
|
|
|
|
// },
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
client: {
|
|
|
|
|
overlay: false,
|
|
|
|
|
},
|
2025-03-12 13:38:44 +08:00
|
|
|
},
|
2025-03-12 23:31:59 +08:00
|
|
|
});
|