import { defineConfig, loadEnv } from 'vite' import react from '@vitejs/plugin-react' import tailwindcss from '@tailwindcss/vite' // Development server. /api and /media are proxied to the FastAPI backend so the // browser talks to a single origin (no CORS issues, relative media URLs work). export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), '') const backend = env.VITE_BACKEND_URL || 'http://127.0.0.1:8020' return { plugins: [react(), tailwindcss()], server: { host: '127.0.0.1', port: 5173, strictPort: true, // Allow access through the ngrok tunnel. allowedHosts: ['emphatic-cake-purebred.ngrok-free.dev'], proxy: { '/api': { target: backend, changeOrigin: true }, '/media': { target: backend, changeOrigin: true }, }, }, preview: { host: '127.0.0.1', port: 5173, allowedHosts: ['emphatic-cake-purebred.ngrok-free.dev'], }, } })