Moved documentation files into a new docs/ directory and added a documentation index (docs/README.md). Updated the main README with improved project and documentation details. Set explicit API environment variables in Dockerfile for production. Enhanced next.config.mjs with improved API_BASE_URL handling and logging for better deployment clarity.
2.2 KiB
2.2 KiB
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:
# 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:
# 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:
# 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
- Undefined variables: Set all required variables in CapRover
- Invalid URLs: Ensure no trailing slashes in API_BASE_URL
- HTTPS vs HTTP: Match your backend's protocol
Verification
After deployment, check:
- App starts without 500 errors
- API requests work correctly
- No console warnings about undefined variables
🚀 Deploy Steps
- Set environment variables in CapRover
- Commit and push changes
- Redeploy the app
- Check logs for successful startup
📝 Notes
- The
next.config.mjsnow has safer fallbacks to prevent 500 errors - Missing variables will log warnings but won't crash the app
- For local development, use the
.envfile as before