WebMusic/webapp/vite.config.js

29 lines
657 B
JavaScript
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'
export default defineConfig({
plugins: [vue()],
server: {
port: 5173,
host: true,
proxy: {
// 将 /api 路径代理到后端服务器
'/api': {
target: 'http://localhost:7001',
changeOrigin: true,
rewrite: (path) => path, // 保持路径不变
},
// WebSocket代理
'/ws': {
target: 'http://localhost:7001',
ws: true,
changeOrigin: true,
},
},
},
// 确保所有路由都返回 index.htmlSPA 路由支持)
// Vite 开发服务器默认支持 history API fallback
})