add ws
Some checks failed
Deploy / deploy (push) Has been cancelled

This commit is contained in:
2025-10-07 17:04:35 +08:00
parent 437da9d588
commit 389393b70d
3 changed files with 575 additions and 73 deletions

View File

@@ -16,6 +16,14 @@ export default defineConfig(({ envMode }) => {
headers: { Referer: url },
changeOrigin: true,
}
// WebSocket 代理配置(开发环境 Daphne 在 8001 端口)
const wsProxyConfig = {
target: url.replace(':8000', ':8001').replace('http:', 'ws:'), // http://localhost:8001 → ws://localhost:8001
ws: true, // 启用 WebSocket 代理
changeOrigin: true,
logLevel: 'debug' as const, // 显示代理日志
}
return {
plugins: [pluginVue()],
tools: {
@@ -141,6 +149,7 @@ export default defineConfig(({ envMode }) => {
proxy: {
"/api": proxyConfig,
"/public": proxyConfig,
"/ws": wsProxyConfig, // WebSocket 使用单独的代理配置
},
},
}