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

const SUPERADMIN_SERVER_PORT = process.env.SUPERADMIN_PORT || '3002';
const SUPERADMIN_SERVER_HOST = process.env.SUPERADMIN_SERVER_HOST || 'http://localhost';

export default defineConfig({
  plugins: [react()],
  server: {
    port: Number(process.env.VITE_PORT) || 3003,
    strictPort: true,
    host: true,
    proxy: {
      '/api': {
        target: `${SUPERADMIN_SERVER_HOST}:${SUPERADMIN_SERVER_PORT}`,
        changeOrigin: true,
        secure: false
      }
    }
  },
  preview: {
    port: Number(process.env.VITE_PORT) || 3003,
    strictPort: true
  }
});