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

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