Overview
Popcorn Vision is built with Next.js 14, making it deployable to any platform that supports Next.js applications. This guide covers deployment to popular platforms and self-hosted environments.Popcorn Vision uses Next.js App Router and requires a platform that supports Next.js 14+ features.
Quick Deploy Options
Vercel
RecommendedZero-config deployment with automatic optimizations. Best for Next.js apps.
Netlify
Easy SetupSimple deployment with good Next.js support via their plugin.
Self-Hosted
Full ControlDeploy to your own VPS, Docker container, or cloud provider.
Prerequisites
Before deploying, ensure you have:TMDB API Credentials
Obtain your API key and Read Access Token from TMDB. See TMDB API Setup for details.
Environment Variables Ready
Prepare all required environment variables from Environment Configuration.
Deploy to Vercel
Vercel is the recommended platform for Next.js applications, offering zero-config deployment and automatic optimizations.One-Click Deploy
The fastest way to deploy:Click Deploy Button
Use the Deploy to Vercel button from the Popcorn Vision repository (if available), or manually import:
- Go to Vercel
- Click Add New > Project
- Import your Git repository
Deploy
Click Deploy and wait for the build to complete.Vercel will:
- Install dependencies
- Build your Next.js application
- Deploy to a production URL
- Generate preview URLs for pull requests
Manual CLI Deploy
Deploy using Vercel CLI:Vercel Configuration
Popcorn Vision works with default Vercel settings, but you can customize withvercel.json:
vercel.json
Deploy to Netlify
Netlify supports Next.js through their Essential Next.js plugin.Connect Repository
- Log in to Netlify
- Click Add new site > Import an existing project
- Connect your Git provider and select your repository
Configure Build Settings
Netlify should auto-detect Next.js. Verify these settings:Build command:
npm run build or pnpm buildPublish directory: .nextFunctions directory: .netlify/functionsEnable Next.js Plugin
The Essential Next.js plugin should be automatically enabled. If not:
- Go to Integrations
- Search for “Essential Next.js”
- Install and enable the plugin
Netlify Configuration
Create anetlify.toml file in your project root:
netlify.toml
Self-Hosted Deployment
Deploy Popcorn Vision to your own infrastructure.Using Node.js Server
Using Docker
Deploy with Docker for containerized deployment:You’ll need to enable Next.js standalone output in
next.config.mjs for Docker:Build Configuration
Popcorn Vision’s build configuration is defined innext.config.mjs:
next.config.mjs
Key Configuration Options
React Strict Mode for identifying potential problems. Disabled by default for production performance.
Cache duration (in seconds) for dynamic routes. Set to 3600 (1 hour) to reduce TMDB API calls.
Cache duration (in seconds) for static routes. Helps with build-time optimizations.
Optional Optimizations
For production deployments, consider these additional options:next.config.mjs
Performance Optimization
Enable Image Optimization
Enable Image Optimization
Configure Next.js Image component to use TMDB’s CDN:
next.config.mjs
Configure Caching Strategy
Configure Caching Strategy
Popcorn Vision uses aggressive caching to minimize API calls:
- Static content: Cached indefinitely
- Dynamic routes: Revalidated every hour
- API responses: Cached for 1 hour
staleTimes in next.config.mjs based on your needs.Use CDN for Static Assets
Use CDN for Static Assets
Deploy static assets (images, CSS, JS) to a CDN:Then set
next.config.mjs
CDN_URL environment variable to your CDN domain.Enable Compression
Enable Compression
Ensure gzip/brotli compression is enabled:Most hosting platforms (Vercel, Netlify) enable this automatically.
next.config.mjs
Monitor Performance
Monitor Performance
Use Google Analytics (configured via
GA_MEASUREMENT_ID) or integrate other monitoring tools:- Vercel Analytics
- Sentry for error tracking
- LogRocket for session replay
Troubleshooting
Build Fails with Environment Variable Errors
Build Fails with Environment Variable Errors
Problem: Build fails with “API_KEY is not defined” or similar.Solution:
Ensure environment variables are set in your deployment platform:
- Vercel: Project Settings > Environment Variables
- Netlify: Site Settings > Environment Variables
- Self-hosted: Set in
.env.productionfile
API_URLAPI_KEYAPI_READ- All
NEXT_PUBLIC_API_IMAGE_*variables
Images Not Loading in Production
Images Not Loading in Production
Problem: Movie posters show broken image icons.Solutions:
- Verify
NEXT_PUBLIC_API_IMAGE_*variables are set - Check image domain is allowed in
next.config.mjs: - Ensure TMDB CDN is accessible from your deployment region
API Requests Failing (CORS Errors)
API Requests Failing (CORS Errors)
Problem: API calls fail with CORS errors in production.Cause: Direct client-side calls to TMDB API.Solution:
Always use Popcorn Vision’s API routes (
/api/*) instead of calling TMDB directly. These routes proxy requests server-side, avoiding CORS issues.Slow Performance or Timeout Errors
Slow Performance or Timeout Errors
Problem: Pages load slowly or time out.Solutions:
- Enable caching: Verify
staleTimesconfiguration innext.config.mjs - Optimize API calls: Reduce the number of API requests per page
- Use a faster deployment region: Choose a region closer to TMDB servers (US East)
- Implement Redis caching: Cache API responses externally
Application Crashes or Restarts
Application Crashes or Restarts
Problem: Application frequently crashes in production.Solutions:
- Check memory usage - increase if needed
- Review error logs for uncaught exceptions
- Enable error tracking (Sentry, LogRocket)
- Use a process manager (PM2) for automatic restarts
- Check for rate limiting from TMDB API
Custom Domain Not Working
Custom Domain Not Working
Problem: Custom domain shows SSL or DNS errors.Solutions:
- Verify DNS records: Ensure A/CNAME records point to your host
- Wait for propagation: DNS changes can take 24-48 hours
- SSL certificate: Most platforms auto-generate SSL certs
- Update environment: Set production URL in your config if needed
Security Best Practices
Protect API Credentials
Protect API Credentials
- Never commit
.env.localor.env.productionto Git - Use platform environment variables for secrets
- Rotate API keys periodically
- Use different keys for development and production
Enable Security Headers
Enable Security Headers
Add security headers in
next.config.mjs:Rate Limiting
Rate Limiting
Popcorn Vision includes built-in rate limiting. For high-traffic sites, consider:
- Implementing Redis-based rate limiting
- Using a CDN with DDoS protection (Cloudflare)
- Adding IP-based request throttling
Monitor for Suspicious Activity
Monitor for Suspicious Activity
- Enable access logs
- Set up alerts for unusual traffic patterns
- Monitor API usage on TMDB dashboard
- Use error tracking to catch security issues
Post-Deployment Checklist
After deploying, verify everything works correctly:Test Core Functionality
- Homepage loads with trending movies
- Search functionality works
- Movie detail pages display correctly
- Images load properly
- Navigation between pages works
Verify API Integration
- TMDB API calls succeed (check browser Network tab)
- No 401 authentication errors
- Rate limiting is working correctly
- Caching is active (check response headers)
Check Performance
- Page load time < 3 seconds
- Lighthouse score > 90
- Images are optimized
- No console errors
Test on Multiple Devices
- Desktop browsers (Chrome, Firefox, Safari)
- Mobile devices (iOS, Android)
- Different screen sizes
- Dark mode compatibility
Next Steps
Environment Variables
Review all environment variable configuration options
TMDB API
Learn more about TMDB API usage and best practices