import { fileURLToPath, URL } from "node:url"; import { defineConfig, loadEnv } from "vite"; import react from "@vitejs/plugin-react"; // https://vite.dev/config/ export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), ""); // Public path the app is served from; the router basename is derived from it. const base = env.VITE_BASE_PATH || "/online/"; // Backend origin the dev server proxies /api to. const proxyTarget = env.VITE_PROXY_TARGET || "https://test.webulgam.com/online-backend"; const allowedHosts = (env.VITE_ALLOWED_HOSTS || "test.webulgam.com") .split(",") .map((h) => h.trim()) .filter(Boolean); return { base, plugins: [react()], resolve: { alias: { "@": fileURLToPath(new URL("./src", import.meta.url)), }, }, preview: { allowedHosts, }, server: { allowedHosts, proxy: { "/api": { target: proxyTarget, changeOrigin: true, }, }, }, }; });