forked from All-Hands-AI/OpenHands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
32 lines (29 loc) · 866 Bytes
/
vite.config.ts
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
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import viteTsconfigPaths from "vite-tsconfig-paths";
const BACKEND_HOST = process.env.BACKEND_HOST || "127.0.0.1:3000";
// check BACKEND_HOST is something like "example.com"
if (!BACKEND_HOST.match(/^([\w\d-]+(\.[\w\d-]+)+(:\d+)?)/)) {
throw new Error(
`Invalid BACKEND_HOST ${BACKEND_HOST}, example BACKEND_HOST 127.0.0.1:3000`,
);
}
export default defineConfig({
// depending on your application, base can also be "/"
base: "",
plugins: [react(), viteTsconfigPaths()],
server: {
port: 3001,
proxy: {
"/api": {
target: `http://${BACKEND_HOST}/`,
changeOrigin: true,
rewrite: (path: string) => path.replace(/^\/api/, ""),
},
"/ws": {
target: `ws://${BACKEND_HOST}/`,
ws: true,
},
},
},
});