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

export default defineConfig({
  plugins: [vue()],
  server: {
    host: '0.0.0.0',
    port: 5173,
    proxy: {
      // Downloader API - already has /api prefix on backend
      '/api/downloader': {
        target: 'http://backend:8000',
        changeOrigin: true
      },
      // Openings API - already has /api prefix on backend
      '/api/openings': {
        target: 'http://backend:8000',
        changeOrigin: true
      },
      // Backgrounds API - already has /api prefix on backend
      '/api/backgrounds': {
        target: 'http://backend:8000',
        changeOrigin: true
      },
      // Core API endpoints - strip /api prefix
      '/api': {
        target: 'http://backend:8000',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      },
      '/videos': {
        target: 'http://backend:8000',
        changeOrigin: true
      },
      '/download': {
        target: 'http://backend:8000',
        changeOrigin: true
      }
    }
  }
})
