import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import { fileURLToPath, URL } from 'node:url'; const apiTarget = process.env.PIG_API_TARGET ?? 'http://localhost:8920'; export default defineConfig({ plugins: [react()], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) }, }, server: { // Both are overridable so a second checkout (a worktree, a review branch) // can run its own API and web server without colliding with the first. port: Number(process.env.PIG_WEB_PORT ?? 5173), // Proxy in development so the browser sees one origin, matching how // production serves the API and the app together. Auth sessions are // per-origin, so a split origin in dev but not prod hides real bugs. /* * `/media` is proxied as well as `/api`, because Learn videos PIG hosts * itself are served from the API on a non-/api path. Without this entry * Vite answers the