- Add URL utility functions for building resource URLs - Update all components to use relative URLs in production - Add production deployment documentation - Update nginx config to proxy all required endpoints - Add .env.production.example with proper configuration
2.8 KiB
Production Deployment Guide
This guide explains how to deploy PicPeak in production behind a reverse proxy like Traefik.
Environment Configuration
Frontend Configuration
For production deployment behind a reverse proxy (Traefik, Nginx, etc.), the frontend should use relative URLs to automatically inherit the protocol (HTTPS) and domain.
-
Copy the production environment template:
cp frontend/.env.production.example frontend/.env.production -
Set the API URL to use relative path:
# frontend/.env.production VITE_API_URL=/apiThis ensures all API calls will use the same domain and protocol as the frontend.
Backend Configuration
Ensure your backend .env file has the correct URLs:
# backend/.env
FRONTEND_URL=https://yourdomain.com
ADMIN_URL=https://yourdomain.com
Docker Compose Production
When using Docker Compose in production:
-
Build with production environment:
docker-compose -f docker-compose.prod.yml build --build-arg NODE_ENV=production -
The frontend nginx configuration already includes proper proxy settings for:
/api→ Backend API/photos→ Protected photo access/thumbnails→ Thumbnail images/uploads→ Public uploads (logos, favicons)
Traefik Configuration
Example Traefik labels for docker-compose:
services:
frontend:
labels:
- "traefik.enable=true"
- "traefik.http.routers.picpeak.rule=Host(`yourdomain.com`)"
- "traefik.http.routers.picpeak.entrypoints=websecure"
- "traefik.http.routers.picpeak.tls.certresolver=letsencrypt"
- "traefik.http.services.picpeak.loadbalancer.server.port=80"
Important Notes
-
No Hardcoded URLs: The application uses environment variables with relative URL fallbacks, making it production-ready.
-
HTTPS Only: When
VITE_API_URL=/api, all requests will use the same protocol as the page (HTTPS in production). -
CORS Configuration: The backend CORS is configured to accept requests from the URLs specified in
FRONTEND_URLandADMIN_URL. -
Static Assets: All static assets (photos, thumbnails, uploads) are served through the nginx proxy, inheriting authentication headers.
Verification
After deployment, verify:
- Check browser console for any localhost URLs (there should be none)
- Verify all API calls use HTTPS
- Check that images load correctly with authentication
- Test favicon and logo display
Troubleshooting
If you see console errors about localhost:
- Ensure
VITE_API_URL=/apiin frontend environment - Clear browser cache
- Rebuild frontend with production environment:
cd frontend npm run build
If images don't load:
- Check that nginx proxy locations are configured
- Verify authentication tokens are being sent
- Check backend logs for authentication errors