Files
KCGL/inventory-web/vite.config.ts

39 lines
1.0 KiB
TypeScript
Raw Normal View History

2026-01-26 13:47:53 +08:00
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import basicSsl from '@vitejs/plugin-basic-ssl' // ★ [新增] 引入 SSL 插件
import { fileURLToPath, URL } from 'node:url'
2026-01-26 13:47:53 +08:00
export default defineConfig({
plugins: [
vue(),
basicSsl() // ★ [新增] 启用 HTTPS 证书生成
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
2026-02-04 13:30:07 +08:00
// 允许局域网访问前端页面
host: '0.0.0.0',
port: 5173,
strictPort: true,
watch: {
usePolling: true
},
2026-02-05 11:08:29 +08:00
https: true, // ★ [新增] 强制开启 HTTPS否则浏览器会拦截摄像头
hmr: {
protocol: 'wss',
clientPort: 5175
},
proxy: {
2026-02-04 13:30:07 +08:00
// 拦截所有以 /api 开头的请求
'/api': {
2026-02-04 13:30:07 +08:00
// 在 Docker 内部,直接用这个名字作为域名,就能找到它
target: 'http://inventory_api:8000',
changeOrigin: true,
2026-02-04 13:30:07 +08:00
// rewrite: (path) => path.replace(/^\/api/, '')
}
}
}
})