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

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src')
    }
  },
  server: {
    port: 3000,
    open: true,
    // Proxy Qdrant so the api-key stays server-side and the browser avoids CORS.
    // Frontend calls /qdrant/... → forwarded to the Qdrant cluster with the key injected.
    proxy: {
      '/qdrant': {
        target: 'http://66.116.207.225:6333',
        changeOrigin: true,
        rewrite: (p) => p.replace(/^\/qdrant/, ''),
        configure: (proxy) => {
          proxy.on('proxyReq', (proxyReq) => {
            proxyReq.setHeader('api-key', 'Package@321#');
          });
        }
      }
    }
  }
});
