Files
quick-share/frontend/vite.config.ts

33 lines
901 B
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 path from 'path';
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
// 为 sockjs-client 等依赖提供浏览器环境下的 global 替代
define: {
global: 'window',
},
server: {
port: 5173,
// 允许局域网内其它设备访问(如手机、其它电脑)
host: true,
// 开发时代理:前端用同源请求,由 Vite 转发到后端,跨设备访问时无需改 API 地址
// xfwd: true 会把真实客户端 IP 写入 X-Forwarded-For后端 /api/room/my-ip 才能拿到各机器的 IP
proxy: {
'/api': {
target: 'http://localhost:8080',
changeOrigin: true,
xfwd: true,
},
'/ws': { target: 'http://localhost:8080', ws: true },
},
},
});