-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathvite.config.ts
More file actions
83 lines (79 loc) · 3.23 KB
/
vite.config.ts
File metadata and controls
83 lines (79 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import {defineConfig} from "vite";
import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
import path from "path"; // 需要安装 Node.js 的类型声明(@types/node)
// https://vite.dev/config/
export default defineConfig({
plugins: [react(), tailwindcss()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"), // 将 @/ 映射到 src/ 目录
},
},
server: {
host: "0.0.0.0",
proxy: (() => {
const pythonProxyConfig = {
target: "http://localhost:18000",
changeOrigin: true,
secure: false,
configure: (proxy: { on: (event: string, handler: (arg: unknown) => void) => void }) => {
proxy.on("proxyReq", (proxyReq: unknown) => {
(proxyReq as { removeHeader: (name: string) => void }).removeHeader("referer");
(proxyReq as { removeHeader: (name: string) => void }).removeHeader("origin");
});
proxy.on("proxyRes", (proxyRes: unknown) => {
const res = proxyRes as { headers: Record<string, unknown> };
delete res.headers["set-cookie"];
res.headers["cookies"] = "";
});
},
};
const javaProxyConfig = {
target: "http://localhost:8080",
changeOrigin: true,
secure: false,
configure: (proxy: { on: (event: string, handler: (arg: unknown) => void) => void }) => {
proxy.on("proxyReq", (proxyReq: unknown) => {
(proxyReq as { removeHeader: (name: string) => void }).removeHeader("referer");
(proxyReq as { removeHeader: (name: string) => void }).removeHeader("origin");
});
proxy.on("proxyRes", (proxyRes: unknown) => {
const res = proxyRes as { headers: Record<string, unknown> };
delete res.headers["set-cookie"];
res.headers["cookies"] = "";
});
},
};
// Python 服务: rag, synthesis, annotation, evaluation, models
const pythonPaths = ["rag", "cleaning", "operators", "categories", "synthesis", "annotation", "knowledge-base", "data-collection", "evaluation", "models", "sys-param"];
// Java 服务: data-management, knowledge-base
const javaPaths = ["data-management"];
const proxy: Record<string, object> = {};
// SSE 端点需要禁用缓冲
proxy["/api/cleaning"] = {
target: "http://localhost:32033",
changeOrigin: true,
secure: false,
configure: (proxy: { on: (event: string, handler: (arg: unknown) => void) => void }) => {
proxy.on("proxyReq", (proxyReq: unknown) => {
(proxyReq as { removeHeader: (name: string) => void }).removeHeader("referer");
(proxyReq as { removeHeader: (name: string) => void }).removeHeader("origin");
});
proxy.on("proxyRes", (proxyRes: unknown) => {
const res = proxyRes as { headers: Record<string, unknown> };
delete res.headers["set-cookie"];
res.headers["cookies"] = "";
});
},
};
for (const p of pythonPaths) {
proxy[`/api/${p}`] = pythonProxyConfig;
}
for (const p of javaPaths) {
proxy[`/api/${p}`] = javaProxyConfig;
}
return proxy;
})(),
},
});