Overview
HTTPS is a critical requirement when deploying the MC World Compressor Frontend to production environments. This guide explains why HTTPS is necessary, how mixed content policies work, and how to properly configure your deployment.Why HTTPS Matters
Security Benefits
- Data Encryption: All communication between the browser and server is encrypted
- Data Integrity: Prevents tampering with data in transit
- Authentication: Verifies the server’s identity
- User Trust: Modern browsers mark HTTP sites as “Not Secure”
SEO and Performance
- Search engines rank HTTPS sites higher
- HTTP/2 and HTTP/3 require HTTPS for better performance
- Progressive Web App (PWA) features require HTTPS
- Many modern APIs only work over HTTPS
Mixed Content Errors
What Are Mixed Content Errors?
Mixed content occurs when an HTTPS page attempts to load resources over HTTP. Browsers block these requests to protect users from security vulnerabilities. Example Scenario:Types of Mixed Content
Active Mixed Content (Always Blocked):- API requests (fetch, XMLHttpRequest)
- WebSocket connections
- Form submissions
- JavaScript files
- Images
- Audio/Video
- Fonts
Error Messages
You’ll see errors in the browser console like:Why Both Frontend and Backend Need HTTPS
Browser Security Model
Modern browsers enforce strict security policies:- Same Protocol Requirement: HTTPS pages can only make secure requests
- Downgrade Prevention: Prevents attackers from intercepting data
- User Protection: Ensures end-to-end encryption
Data Flow
Even though your frontend talks to the backend, the actual HTTP request comes from the user’s browser, not your frontend server. This is why both must use the same protocol.
Configuration Guide
Frontend Configuration
Set the backend URL with HTTPS in your environment variables:.env
Backend Configuration
Your backend must be configured to accept HTTPS connections. Common approaches:Option 1: Platform-Managed SSL
Use a platform that provides automatic HTTPS:- Railway: Automatic HTTPS for all deployments
- Render: Free SSL certificates
- Fly.io: Automatic SSL
- Heroku: Free SSL certificates
- AWS Elastic Beanstalk: Can enable HTTPS
Option 2: Reverse Proxy (Nginx/Apache)
Use a reverse proxy to handle SSL:Option 3: Let’s Encrypt
Use free SSL certificates from Let’s Encrypt:Option 4: Cloudflare
Use Cloudflare as a reverse proxy:- Point your domain DNS to Cloudflare
- Enable SSL/TLS in Cloudflare dashboard
- Set SSL mode to “Full” or “Full (Strict)”
- Cloudflare provides free SSL certificates
Development vs Production
| Environment | Frontend Protocol | Backend Protocol |
|---|---|---|
| Local Development | HTTP (localhost:3000) | HTTP (localhost:8080) |
| Production | HTTPS (Vercel, etc.) | HTTPS (required) |
In local development, both frontend and backend can use HTTP since mixed content policies don’t apply to localhost.
Testing HTTPS Configuration
1. Verify SSL Certificate
Check that your backend has a valid SSL certificate:2. Test in Browser
- Open your HTTPS frontend in a browser
- Open Developer Tools (F12)
- Go to Console tab
- Look for any mixed content errors
- Test file upload functionality
3. Check Security
Verify SSL configuration quality:- SSL Labs Test: https://www.ssllabs.com/ssltest/
- Check for A or A+ rating
- Ensure modern TLS versions (1.2, 1.3)
Common Issues and Solutions
Issue: Mixed Content Errors
Symptom: File uploads fail with mixed content errors Solution:- Check
NEXT_PUBLIC_BACKEND_URLuseshttps:// - Verify backend is accessible via HTTPS
- Test backend directly:
curl https://your-backend.com - Check browser console for specific error messages
Issue: SSL Certificate Errors
Symptom: “Your connection is not private” or “NET::ERR_CERT_AUTHORITY_INVALID” Solution:- Use a valid SSL certificate from a trusted CA (Let’s Encrypt, etc.)
- Ensure certificate matches your domain
- Check certificate hasn’t expired
- Verify certificate chain is complete
Issue: CORS with HTTPS
Symptom: CORS errors after enabling HTTPS Solution: Update backend CORS configuration to allow HTTPS origin:Issue: Redirect Loops
Symptom: Page keeps redirecting between HTTP and HTTPS Solution:- Configure your platform to enforce HTTPS
- Set proper redirect rules (HTTP → HTTPS)
- Check reverse proxy configuration
Best Practices
1. Always Use HTTPS in Production
2. Enforce HTTPS
Redirect all HTTP traffic to HTTPS:next.config.mjs
3. Use HSTS Headers
Enable HTTP Strict Transport Security:next.config.mjs
4. Monitor Certificate Expiry
- SSL certificates expire (Let’s Encrypt: 90 days)
- Set up automated renewal
- Monitor expiry dates
- Test renewal process
5. Use Environment Variables
Never hardcode URLs in your code:Platform-Specific Guides
Vercel Frontend + Railway Backend
- Frontend: Vercel provides automatic HTTPS
- Backend: Railway provides automatic HTTPS
- Set
NEXT_PUBLIC_BACKEND_URLto Railway’s HTTPS URL
Custom Domain Setup
- Frontend: Add custom domain in Vercel
- Backend: Add custom domain in your backend platform
- Update
NEXT_PUBLIC_BACKEND_URLto custom domain - Update
NEXT_PUBLIC_SITE_URLfor sitemap
Docker Deployment
Use a reverse proxy (Nginx, Traefik, Caddy) in front of containers:docker-compose.yml
Verification Checklist
Before going live:- Frontend is accessible via HTTPS
- Backend is accessible via HTTPS
-
NEXT_PUBLIC_BACKEND_URLuseshttps:// - No mixed content errors in browser console
- File upload works correctly
- SSL certificate is valid and trusted
- SSL certificate won’t expire soon
- CORS is configured for HTTPS origin
- HSTS headers are enabled
- HTTP redirects to HTTPS
