Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(vite.config): Allowed Hosts Defined Through Env Variable

xe43f583eb65b
diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts
index b737527732..618dcb618a 100644
--- a/frontend/vite.config.ts
+++ b/frontend/vite.config.ts
@@ -1,6 +1,6 @@
import { TanStackRouterVite } from "@tanstack/router-plugin/vite";
import react from "@vitejs/plugin-react-swc";
-import { defineConfig, PluginOption } from "vite";
+import { defineConfig, loadEnv, PluginOption } from "vite";
import { nodePolyfills } from "vite-plugin-node-polyfills";
import topLevelAwait from "vite-plugin-top-level-await";
import wasm from "vite-plugin-wasm";
@@ -20,32 +20,38 @@ const virtualRouteFileChangeReloadPlugin: PluginOption = {
};
// https://vite.dev/config/
-export default defineConfig({
- server: {
- host: true,
- port: 3000
- // proxy: {
- // "/api": {
- // target: "http://localhost:8080",
- // changeOrigin: true,
- // secure: false,
- // ws: true
- // }
- // }
- },
- plugins: [
- tsconfigPaths(),
- nodePolyfills({
- globals: {
- Buffer: true
- }
- }),
- wasm(),
- topLevelAwait(),
- TanStackRouterVite({
- virtualRouteConfig: "./src/routes.ts"
- }),
- react(),
- virtualRouteFileChangeReloadPlugin
- ]
+export default defineConfig(({ mode }) => {
+ const env = loadEnv(mode, process.cwd());
+ const allowedHosts = env.VITE_ALLOWED_HOSTS?.split(",") ?? [];
+
+ return {
+ server: {
+ allowedHosts,
+ host: true,
+ port: 3000
+ // proxy: {
+ // "/api": {
+ // target: "http://localhost:8080",
+ // changeOrigin: true,
+ // secure: false,
+ // ws: true
+ // }
+ // }
+ },
+ plugins: [
+ tsconfigPaths(),
+ nodePolyfills({
+ globals: {
+ Buffer: true
+ }
+ }),
+ wasm(),
+ topLevelAwait(),
+ TanStackRouterVite({
+ virtualRouteConfig: "./src/routes.ts"
+ }),
+ react(),
+ virtualRouteFileChangeReloadPlugin
+ ]
+ };
});