Spaces:
Running
Running
| import { defineConfig, loadEnv } from 'vite' | |
| import react from '@vitejs/plugin-react' | |
| // https://vitejs.dev/config/ | |
| export default defineConfig(({ mode }) => { | |
| // Load env file based on `mode` in the current working directory. | |
| const env = loadEnv(mode, process.cwd(), '') | |
| return { | |
| plugins: [react()], | |
| define: { | |
| // Inject the API Key securely from the runtime environment | |
| 'process.env.API_KEY': JSON.stringify(process.env.API_KEY || env.API_KEY) | |
| }, | |
| server: { | |
| host: '0.0.0.0', // Critical for Docker | |
| port: 7860, // Critical for HF Spaces | |
| strictPort: true, | |
| hmr: { | |
| clientPort: 443 // Fixes HMR behind Hugging Face SSL proxy | |
| }, | |
| allowedHosts: ['.hf.space', 'localhost'] // Allow HF domains | |
| } | |
| } | |
| }) |