mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 13:52:43 +08:00
41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
/// <reference types="vitest" />
|
|
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()],
|
|
clearScreen: false,
|
|
server: {
|
|
port: process.env.FRONTEND_PORT
|
|
? Number.parseInt(process.env.FRONTEND_PORT, 10)
|
|
: 3001,
|
|
proxy: {
|
|
"/api": {
|
|
target: `http://${BACKEND_HOST}/`,
|
|
changeOrigin: true,
|
|
},
|
|
"/ws": {
|
|
target: `ws://${BACKEND_HOST}/`,
|
|
ws: true,
|
|
},
|
|
},
|
|
},
|
|
test: {
|
|
environment: "jsdom",
|
|
globals: true,
|
|
setupFiles: ["vitest.setup.ts"],
|
|
},
|
|
});
|