langflow/src/frontend/vite.config.ts
2023-06-15 07:37:26 -03:00

31 lines
703 B
TypeScript

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import svgr from "vite-plugin-svgr";
const apiRoutes = ["^/api/v1/", "/health"];
// Use environment variable to determine the target.
const target = process.env.VITE_PROXY_TARGET || "http://127.0.0.1:7860";
const proxyTargets = apiRoutes.reduce((proxyObj, route) => {
proxyObj[route] = {
target: target,
changeOrigin: true,
secure: false,
ws: true,
};
return proxyObj;
}, {});
export default defineConfig(() => {
return {
build: {
outDir: "build",
},
plugins: [react(), svgr()],
server: {
port: 3000,
proxy: {
...proxyTargets,
},
},
};
});