# CapRover Deployment Fix for 500 Errors ## 🚨 Issue The domain privacy changes require specific environment variables to be set in CapRover. Missing these causes 500 errors during deployment. ## ✅ Required Environment Variables in CapRover ### **Step 1: Set Environment Variables** In your CapRover app settings, add these environment variables: ```bash # Required for API routing API_BASE_URL=https://your-backend-domain.com API_HOSTNAME=your-backend-domain.com SERVER_API_URL=https://your-backend-domain.com/api # Client-side API URL (should already be set) NEXT_PUBLIC_API_URL=/api ``` ### **Step 2: Example Configuration** Replace `your-backend-domain.com` with your actual backend domain: ```bash # For production deployment API_BASE_URL=https://internal-api.inboxi.ng API_HOSTNAME=internal-api.inboxi.ng SERVER_API_URL=https://internal-api.inboxi.ng/api NEXT_PUBLIC_API_URL=/api ``` ### **Step 3: Alternative - Use Internal Service Names** If using CapRover's internal networking: ```bash # Using CapRover internal service names API_BASE_URL=http://srv-captain--your-backend-app-name API_HOSTNAME=srv-captain--your-backend-app-name SERVER_API_URL=http://srv-captain--your-backend-app-name/api NEXT_PUBLIC_API_URL=/api ``` ## 🔧 Troubleshooting ### **Check Environment Variables** In CapRover app logs, you should see: ``` Building with environment: - API_BASE_URL: https://your-domain.com - API_HOSTNAME: your-domain.com - SERVER_API_URL: https://your-domain.com/api ``` ### **Common Issues** 1. **Undefined variables**: Set all required variables in CapRover 2. **Invalid URLs**: Ensure no trailing slashes in API_BASE_URL 3. **HTTPS vs HTTP**: Match your backend's protocol ### **Verification** After deployment, check: 1. App starts without 500 errors 2. API requests work correctly 3. No console warnings about undefined variables ## 🚀 Deploy Steps 1. Set environment variables in CapRover 2. Commit and push changes 3. Redeploy the app 4. Check logs for successful startup ## 📝 Notes - The `next.config.mjs` now has safer fallbacks to prevent 500 errors - Missing variables will log warnings but won't crash the app - For local development, use the `.env` file as before