/**
 * BACKEND URL CONFIGURATION - SINGLE SOURCE OF TRUTH
 * To switch between environments, simply comment/uncomment the URLs below
 */

// ========================================
// LIVE PRODUCTION URLS (Currently Active)
// ========================================
// const FRONTEND_URL = 'https://dashboard.codenuk.com';
// const BACKEND_URL = 'https://backend.codenuk.com';

// ========================================
// LOCAL DEVELOPMENT URLS
// ========================================
const FRONTEND_URL = 'http://192.168.1.17:3001';
const BACKEND_URL = 'http://192.168.1.17:8000';

// ========================================
// CORS CONFIGURATION (Auto-generated)
// ========================================
const CORS_CONFIG = {
  ORIGIN: FRONTEND_URL,
  METHODS: 'GET,POST,PUT,DELETE,PATCH,OPTIONS',
  CREDENTIALS: true,
};

// ========================================
// EXPORTS
// ========================================
module.exports = {
  FRONTEND_URL,
  BACKEND_URL,
  CORS_CONFIG,
  
  // Helper functions
  getApiUrl: (endpoint) => {
    const cleanEndpoint = endpoint.startsWith('/') ? endpoint.slice(1) : endpoint;
    return `${BACKEND_URL}/${cleanEndpoint}`;
  },
  
  // Email verification URL helper
  getVerificationUrl: (token) => {
    return `${FRONTEND_URL}/verify-email?token=${encodeURIComponent(token)}`;
  },
};
