/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  // output: 'standalone', // Only needed for Docker deployment
  
  // Redirects from old routes to new Terminal routes
  async redirects() {
    return [
      // Old Command Center routes
      {
        source: '/command',
        destination: '/terminal/radar',
        permanent: true,
      },
      {
        source: '/command/:path*',
        destination: '/terminal/:path*',
        permanent: true,
      },
      // Dashboard → RADAR
      {
        source: '/terminal/dashboard',
        destination: '/terminal/radar',
        permanent: true,
      },
      // Pricing → INTEL
      {
        source: '/terminal/pricing',
        destination: '/terminal/intel',
        permanent: true,
      },
      {
        source: '/terminal/pricing/:tld*',
        destination: '/terminal/intel/:tld*',
        permanent: true,
      },
      // Listings → LISTING
      {
        source: '/terminal/listings',
        destination: '/terminal/listing',
        permanent: true,
      },
      // Auctions & Marketplace → MARKET
      {
        source: '/terminal/auctions',
        destination: '/terminal/market',
        permanent: true,
      },
      {
        source: '/terminal/marketplace',
        destination: '/terminal/market',
        permanent: true,
      },
      // Portfolio → WATCHLIST (combined)
      {
        source: '/terminal/portfolio',
        destination: '/terminal/watchlist',
        permanent: true,
      },
      // Alerts → RADAR (will be integrated)
      {
        source: '/terminal/alerts',
        destination: '/terminal/radar',
        permanent: true,
      },
      // SEO → RADAR (premium feature, hidden for now)
      {
        source: '/terminal/seo',
        destination: '/terminal/radar',
        permanent: true,
      },
    ]
  },
  
  // Proxy API requests to backend
  // This ensures /api/v1/* works regardless of how the server is accessed
  async rewrites() {
    // Determine backend URL based on environment
    const backendUrl = process.env.BACKEND_URL || 'http://127.0.0.1:8000'
    
    return [
      {
        source: '/api/v1/:path*',
        destination: `${backendUrl}/api/v1/:path*`,
      },
    ]
  },
}

module.exports = nextConfig

