diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 8173d08..54c6dd8 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -1,7 +1,13 @@ import { sveltekit } from '@sveltejs/kit/vite'; +// Dev API target. Defaults to the live API so `npm run dev` works on its own +// (no local backend to run). To test LOCAL backend changes, start a host API +// (`goodnews serve --port 8000`) and run: +// GOODNEWS_DEV_API=http://127.0.0.1:8000 npm run dev +const API = process.env.GOODNEWS_DEV_API || 'https://upbeatbytes.com'; +const proxy = { target: API, changeOrigin: true, secure: true }; + export default { plugins: [sveltekit()], - // Dev convenience: proxy API calls to the FastAPI server. - server: { proxy: { '/api': 'http://127.0.0.1:8000', '/healthz': 'http://127.0.0.1:8000' } }, + server: { proxy: { '/api': proxy, '/healthz': proxy } }, };