Overview
The MC World Compressor Frontend is a Next.js application that can be deployed to various production environments. This guide covers the build process, production server setup, and deployment best practices.Build Process
To build the application for production, run the build command:- Compiles the Next.js application
- Optimizes assets and bundles
- Generates static pages where possible
- Prepares the application for production deployment
Post-Build Tasks
After the build completes, apostbuild script automatically runs to generate the sitemap:
next-sitemap.config.js and includes:
- Multi-language routes (EN, ES, HI, AR)
- Dynamic routes for upload, download, and status pages
- Automatic
robots.txtgeneration - Site URL from
NEXT_PUBLIC_SITE_URLenvironment variable (defaults tohttps://mcworldcompressor.vercel.app)
Production Server
After building, start the production server:- Serves the optimized application
- Handles server-side rendering (SSR)
- Manages API routes
- Serves static assets efficiently
The production server runs on port 3000 by default. You can change this by setting the
PORT environment variable.Deployment Platforms
Vercel (Recommended)
The application is optimized for deployment on Vercel, the platform built by the creators of Next.js. Advantages:- Zero-configuration deployment
- Automatic HTTPS
- Edge network for global performance
- Automatic preview deployments for pull requests
- Built-in analytics and monitoring
- Push your code to a Git repository (GitHub, GitLab, Bitbucket)
- Import the project in Vercel
- Configure environment variables (see Environment Variables)
- Deploy
Other Platforms
The application can also be deployed to:- Docker: Create a Dockerfile with Node.js, install dependencies, build, and run
npm start - Traditional Hosting: Any Node.js hosting provider (DigitalOcean, AWS, etc.)
- Serverless: AWS Lambda, Google Cloud Functions (with Next.js serverless adapter)
Production Checklist
Before deploying to production:- Set
NEXT_PUBLIC_BACKEND_URLto your production backend URL - Ensure backend is accessible via HTTPS if frontend uses HTTPS
- Set
NEXT_PUBLIC_SITE_URLfor correct sitemap generation - Test the build locally with
npm run build && npm start - Verify all environment variables are configured
- Test file upload functionality (up to 4GB)
- Verify multi-language support works correctly
- Check robots.txt and sitemap.xml generation
Build Output
The build process creates:.next/- Compiled application and optimized assetspublic/sitemap.xml- Generated sitemap (after postbuild)public/robots.txt- Generated robots.txt (after postbuild)
The
.next directory should not be committed to version control. It’s generated during the build process.Performance Optimization
The Next.js build automatically includes:- Code splitting: Loads only necessary JavaScript for each page
- Image optimization: Automatic image optimization with Next.js Image component
- Bundle analysis: Use
npm run buildto see bundle sizes - Static generation: Pre-renders pages where possible for faster loading
Monitoring
After deployment, monitor:- Application logs for errors
- Response times and performance metrics
- Upload success rates
- Backend connectivity (CORS, HTTPS issues)
- Memory and CPU usage
Troubleshooting
Build Failures
If the build fails:- Check for TypeScript or ESLint errors:
npm run lint - Ensure all dependencies are installed:
npm install - Verify Node.js version compatibility (Next.js 16+ requires Node.js 18.17+)
- Clear cache:
rm -rf .nextand rebuild
Production Runtime Issues
- Mixed Content Errors: See HTTPS Requirements
- Backend Connection Failed: Verify
NEXT_PUBLIC_BACKEND_URLis correct and accessible - 404 Errors: Ensure all routes are properly configured and built
- Performance Issues: Check bundle sizes and enable caching headers
