langflow/src/frontend/vite.config.mts
Lucas Oliveira 0d60fbf3e7
fix: auto saving config (#3395)
* remove env definition from vite

* add get config query

* add save config hook to add info to autosaving and axios

* Use save config hook to get info

* Create autoSaving variable on flowsManagerStore

* Adds autoSaving from store into every place that used the env variables

* fix wrong url

---------

Co-authored-by: anovazzi1 <otavio2204@gmail.com>
2024-08-16 17:23:11 -03:00

48 lines
1.3 KiB
TypeScript

import react from "@vitejs/plugin-react-swc";
import dotenv from "dotenv";
import path from "path";
import { defineConfig } from "vite";
import svgr from "vite-plugin-svgr";
import tsconfigPaths from "vite-tsconfig-paths";
export default defineConfig(({ mode }) => {
dotenv.config({ path: path.resolve(__dirname, "../../.env") });
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";
// Use environment variable to determine the UI server port
const port = Number(process.env.VITE_PORT) || 3000;
const proxyTargets = apiRoutes.reduce((proxyObj, route) => {
proxyObj[route] = {
target: target,
changeOrigin: true,
secure: false,
ws: true,
};
return proxyObj;
}, {});
return {
build: {
outDir: "build",
},
define: {
"process.env.BACKEND_URL": JSON.stringify(process.env.BACKEND_URL),
"process.env.ACCESS_TOKEN_EXPIRE_SECONDS": JSON.stringify(
process.env.ACCESS_TOKEN_EXPIRE_SECONDS,
),
"process.env.CI": JSON.stringify(process.env.CI),
},
plugins: [react(), svgr(), tsconfigPaths()],
server: {
port: port,
proxy: {
...proxyTargets,
},
},
};
});