* 📝 (frontend): add IS_AUTO_LOGIN constant to handle auto login functionality 🔧 (frontend): update API calls to consider IS_AUTO_LOGIN constant for authentication errors ♻️ (frontend): refactor useGetAutoLogin to handle auto login retries and errors ♻️ (frontend): refactor usePostRefreshAccess to handle auto login retries ♻️ (frontend): refactor request processor to include retry logic with exponential backoff 🔧 (frontend): update Vite config to include LANGFLOW_AUTO_LOGIN environment variable * 🐛 (constants.ts): fix logic in IS_AUTO_LOGIN constant to correctly evaluate the auto login condition based on the environment variable LANGFLOW_AUTO_LOGIN * ✨ (index.tsx): Add support for testMockAutoLogin to simulate auto login for testing purposes 🔧 (constants.ts): Refactor IS_AUTO_LOGIN to handle optional chaining for process.env properties ✨ (auto-login-off.spec.ts): Add test cases to simulate auto login behavior for testing 🔧 (vite.config.mts): Update vite configuration to load environment variables from .env file and handle optional chaining for envLangflow properties
65 lines
1.6 KiB
TypeScript
65 lines
1.6 KiB
TypeScript
import react from "@vitejs/plugin-react-swc";
|
|
import * as dotenv from "dotenv";
|
|
import path from "path";
|
|
import { defineConfig, loadEnv } from "vite";
|
|
import svgr from "vite-plugin-svgr";
|
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
import {
|
|
API_ROUTES,
|
|
BASENAME,
|
|
PORT,
|
|
PROXY_TARGET,
|
|
} from "./src/customization/config-constants";
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), "");
|
|
|
|
const envLangflowResult = dotenv.config({
|
|
path: path.resolve(__dirname, "../../.env"),
|
|
});
|
|
|
|
const envLangflow = envLangflowResult.parsed || {};
|
|
|
|
const apiRoutes = API_ROUTES || ["^/api/v1/", "/health"];
|
|
|
|
const target =
|
|
env.VITE_PROXY_TARGET || PROXY_TARGET || "http://127.0.0.1:7860";
|
|
|
|
const port = Number(env.VITE_PORT) || PORT || 3000;
|
|
|
|
const proxyTargets = apiRoutes.reduce((proxyObj, route) => {
|
|
proxyObj[route] = {
|
|
target: target,
|
|
changeOrigin: true,
|
|
secure: false,
|
|
ws: true,
|
|
};
|
|
return proxyObj;
|
|
}, {});
|
|
|
|
return {
|
|
base: BASENAME || "",
|
|
build: {
|
|
outDir: "build",
|
|
},
|
|
define: {
|
|
"process.env.BACKEND_URL": JSON.stringify(
|
|
envLangflow.BACKEND_URL ?? "http://127.0.0.1:7860",
|
|
),
|
|
"process.env.ACCESS_TOKEN_EXPIRE_SECONDS": JSON.stringify(
|
|
envLangflow.ACCESS_TOKEN_EXPIRE_SECONDS ?? 60,
|
|
),
|
|
"process.env.CI": JSON.stringify(envLangflow.CI ?? false),
|
|
"process.env.LANGFLOW_AUTO_LOGIN": JSON.stringify(
|
|
envLangflow.LANGFLOW_AUTO_LOGIN ?? true,
|
|
),
|
|
},
|
|
plugins: [react(), svgr(), tsconfigPaths()],
|
|
server: {
|
|
port: port,
|
|
proxy: {
|
|
...proxyTargets,
|
|
},
|
|
},
|
|
};
|
|
});
|