Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MC-World-Compressor/Frontend/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Environment variables configure the application’s behavior in different environments. The MC World Compressor Frontend uses environment variables to connect to the backend API and configure deployment settings.Setup
Development Environment
Create a.env file in the project root by copying the example file:
.env to set your local backend URL.
Production Environment
For production deployments:- Vercel: Set environment variables in the Vercel dashboard under Project Settings → Environment Variables
- Docker: Pass variables using
-eflags ordocker-compose.yml - Traditional Hosting: Set variables in your server’s environment or use a
.env.productionfile
Required Variables
The URL of the MC World Compressor backend API.Example Development:Example Production:Important Notes:
- The
NEXT_PUBLIC_prefix makes this variable accessible in the browser - Without this variable, the application cannot communicate with the backend
- Must be a valid URL without trailing slash
- Must be accessible from the user’s browser (public URL, not internal)
Optional Variables
The canonical URL of your deployed frontend application. Used for sitemap generation.Default:Example Custom Domain:This variable is used by
next-sitemap to generate correct URLs in:sitemap.xmlrobots.txt
The port the production server listens on.Default: Only relevant when running the production server with
3000Example:npm start or in containerized environments.Environment-Specific Configuration
Development vs Production
| Variable | Development | Production |
|---|---|---|
NEXT_PUBLIC_BACKEND_URL | http://localhost:8080 | https://api.example.com |
NEXT_PUBLIC_SITE_URL | Not needed | Your production domain |
PORT | 3000 (default) | Platform-specific |
HTTPS Requirements
Security Best Practices
Public vs Private Variables
Public Variables (prefixed withNEXT_PUBLIC_):
- Accessible in browser JavaScript
- Embedded in the client-side bundle
- Visible to end users
- Use for API URLs, public configuration
- Only available on the server
- NOT accessible in browser
- Use for API keys, secrets, database URLs
Validation
The application should validate environment variables at startup. Check for:- Required variables are set
- URLs are properly formatted
- HTTPS is used when required
Verification
After setting environment variables, verify they’re working:During Development
- Start the dev server:
npm run dev - Open browser console
- Check that API requests go to the correct backend URL
- Test file upload functionality
In Production
- Build the application:
npm run build - Check build output for any warnings about missing variables
- Start production server:
npm start - Test API connectivity
- Verify sitemap.xml has correct domain
Troubleshooting
Variable Not Found
Symptom: Application shows undefined or default values Solutions:- Restart the dev server after changing
.envfiles - Rebuild the application for production:
npm run build - Check variable names match exactly (case-sensitive)
- Ensure
NEXT_PUBLIC_prefix for client-side variables
Mixed Content Errors
Symptom: “Mixed Content” errors in browser console Solutions:- Change
NEXT_PUBLIC_BACKEND_URLto use HTTPS - Deploy backend with HTTPS enabled
- See HTTPS Requirements
Sitemap Has Wrong Domain
Symptom:sitemap.xml shows incorrect URLs
Solutions:
- Set
NEXT_PUBLIC_SITE_URLto your production domain - Rebuild:
npm run build - Verify
public/sitemap.xmlhas correct URLs
Example Configurations
Local Development
.env
Production (Vercel)
Docker Deployment
docker-compose.yml
