Files
VibeCoding/WebRTCSignalServerWeb/vite.config.ts
TongTongStudio e6ed7c8e3e feat(webrtc): 完善前端会话恢复、设备绑定与开发代理配置
- 控制端新增页面刷新后自动恢复登录会话,并展示恢复中状态
- 支持被控端配对码绑定、设备在线状态标记及离线设备禁用连接
- 优化登录流程,支持双因子验证码输入
- 修复 API 客户端令牌刷新逻辑,增加认证失败统一回调
- 信令地址支持环境变量推导,ICE 服务器支持自定义配置
- 管理后台强制开发态走 Vite 代理,避免跨域和 IP 不可达问题
- 修复 tsconfig.node.json 产物干扰 vite 配置加载的构建问题
- 添加 .env.example 作为环境变量配置模板
2026-08-03 02:44:52 +08:00

36 lines
1.1 KiB
TypeScript
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.
import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
import { fileURLToPath, URL } from 'node:url';
// 开发态一律走 Vite 同源代理:前端只请求相对路径 /api/**
// 由 dev server 转发到 VITE_API_TARGET 指向的后端。
// 这样浏览器侧不存在跨域,也不会因为「访问 dev server 用的主机名/协议」
// 与「后端绝对地址」不一致而出现 Failed to fetch。
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
// 代理目标:优先 VITE_API_TARGET兼容旧的 VITE_API_BASE默认本机后端。
const target = env.VITE_API_TARGET || env.VITE_API_BASE || 'http://localhost:8080';
// 启动时打印,便于确认请求究竟被转发到哪台后端。
console.log(`[vite] /api -> ${target}`);
return {
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
server: {
host: true,
port: 5180,
proxy: {
'/api': {
target,
changeOrigin: true,
secure: false,
},
},
},
};
});