diff options
| author | Pawel Zelawski <pawel@pzelawski.com> | 2026-05-23 11:11:53 +0200 |
|---|---|---|
| committer | Pawel Zelawski <pawel@pzelawski.com> | 2026-05-23 11:11:53 +0200 |
| commit | 04d93d7d235d328ef40c9dae4e1f56dc8a5e893f (patch) | |
| tree | b1da6b01a7ce0acbeeba3d3b1b3c25b43864bcdb /vite.config.ts | |
| parent | b4369d9d0f700869fd82f64bdc3af012a1ce5bd9 (diff) | |
feat: harden demo security and add full test suite
Diffstat (limited to 'vite.config.ts')
| -rw-r--r-- | vite.config.ts | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/vite.config.ts b/vite.config.ts index 69d80d1..6f8126d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,17 +1,22 @@ -import { defineConfig } from 'vite'; +import { defineConfig, loadEnv } from 'vite'; import react from '@vitejs/plugin-react'; -// https://vitejs.dev/config/ -export default defineConfig({ - plugins: [react()], - server: { - proxy: { - // Proxy /api requests to the backend server (running on port 3000 now) - '/api': { - target: 'http://localhost:3000', // Adjust to match backend PORT from .env - changeOrigin: true, // Recommended for virtual hosted sites - secure: false, // Don't verify SSL certs if backend uses self-signed cert in dev +export default defineConfig(({ mode }) => { + const env = loadEnv(mode, process.cwd(), ''); + const backendPort = env.PORT ?? '3001'; + const backendTarget = + env.VITE_API_PROXY_TARGET ?? `http://localhost:${backendPort}`; + + return { + plugins: [react()], + server: { + proxy: { + '/api': { + target: backendTarget, + changeOrigin: true, + secure: false, + }, }, }, - }, -});
\ No newline at end of file + }; +}); |
