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()],
  server: { proxy: { '/api': proxy, '/healthz': proxy } },
};
