import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

// /auth (login + session status) is served by the public portal; the ops
// console API (/api/ops/v1) lives in the standalone memind_adm service.
const authProxy = process.env.OPS_API_PROXY ?? 'http://127.0.0.1:8081';
const adminProxy = process.env.OPS_ADMIN_PROXY ?? 'http://127.0.0.1:8082';

export default defineConfig({
  base: '/ops/',
  plugins: [react()],
  server: {
    host: '0.0.0.0',
    port: 3002,
    allowedHosts: ['127.0.0.1', 'localhost', '.localhost'],
    proxy: {
      '/admin-api': adminProxy,
      '/api': adminProxy,
      '/auth': authProxy,
    },
  },
  build: {
    outDir: 'dist',
    emptyOutDir: true,
  },
});
