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

export default defineConfig({
    plugins: [react()],
    server: {
        host: '0.0.0.0',
        port: 81,
        strictPort: true,
        allowedHosts: [
            'myrgc.ensup-adm.net',
            'localhost',
            '.ensup-adm.net'
        ],
        watch: {
            usePolling: true
        },
        proxy: {
            '/api': {
                target: 'http://backend:3005',
                changeOrigin: true,
                secure: false,
                configure: (proxy) => {
                    proxy.on('proxyReq', (proxyReq, req) => {
                        console.log('🔀 Proxy /api:', req.method, req.url);
                    });
                }
            },
            '/auth': {
                target: 'http://backend:3005',
                changeOrigin: true,
                secure: false,
                configure: (proxy) => {
                    proxy.on('proxyReq', (proxyReq, req) => {
                        console.log('🔀 Proxy /auth:', req.method, req.url);
                    });
                }
            }
        }
    },
    build: {
        outDir: 'dist',
        sourcemap: true
    }
});