mirror of
https://github.com/johndoe6345789/snippet-pastebin.git
synced 2026-04-24 13:34:55 +00:00
5.6 KiB
5.6 KiB
Deployment Checklist
Quick reference checklist for deploying CodeSnippet with separate frontend and backend domains.
Pre-Deployment
- CapRover server is running and accessible
- Domain name configured in DNS provider (Cloudflare)
- CapRover CLI installed:
npm install -g caprover - Logged into CapRover:
caprover login
DNS Configuration (Cloudflare)
- A record for
frontend.example.com→ CapRover IP (Proxied ☁️) - A record for
backend.example.com→ CapRover IP (Proxied ☁️) - DNS records propagated (check with
digornslookup)
Backend Deployment
- Create app in CapRover:
codesnippet-backend - Enable "Has Persistent Data" with path:
/app/data - Set environment variable:
CORS_ALLOWED_ORIGINS=https://frontend.example.com - Set environment variable:
DATABASE_PATH=/app/data/snippets.db - Deploy code:
cd backend && caprover deploy -a codesnippet-backend - Enable HTTPS in CapRover
- Connect custom domain:
backend.example.com - Force HTTPS redirect enabled
- SSL certificate issued successfully
- Test health endpoint:
curl https://backend.example.com/health
Frontend Deployment
- Create app in CapRover:
codesnippet-frontend - Set environment variable:
VITE_FLASK_BACKEND_URL=https://backend.example.com - Deploy code:
caprover deploy -a codesnippet-frontend(from project root) - Enable HTTPS in CapRover
- Connect custom domain:
frontend.example.com - Force HTTPS redirect enabled
- SSL certificate issued successfully
- Test frontend loads: Visit
https://frontend.example.com
Cloudflare Configuration
- SSL/TLS mode set to "Full (strict)"
- "Always Use HTTPS" enabled
- "Automatic HTTPS Rewrites" enabled
- "Auto Minify" enabled (JS, CSS, HTML)
- "Brotli" compression enabled
Testing
- Backend health check responds:
curl https://backend.example.com/health - CORS preflight test passes (see CORS-GUIDE.md)
- Frontend loads without errors
- Backend indicator shows "Backend" status (not "Local")
- Can create new snippet
- Can view existing snippet
- Can edit snippet
- Can delete snippet
- No CORS errors in browser console (F12)
- Mobile responsive layout works
Post-Deployment
- Database backup strategy configured
- Monitoring enabled (CapRover metrics)
- Rate limiting configured (Cloudflare)
- Error logging reviewed
- Documentation updated with actual URLs
Security Verification
- Both domains use HTTPS only
CORS_ALLOWED_ORIGINSset to specific domain (not*)- Flask debug mode disabled (
debug=False) - No sensitive data in environment variables
- CapRover firewall rules configured
- Cloudflare security features enabled
Quick Commands
Deploy Backend
cd backend
caprover deploy -a codesnippet-backend
Deploy Frontend
caprover deploy -a codesnippet-frontend
Check Backend Logs
caprover logs codesnippet-backend --lines 100 --follow
Check Frontend Logs
caprover logs codesnippet-frontend --lines 100 --follow
Test CORS
curl -X OPTIONS https://backend.example.com/api/snippets \
-H "Origin: https://frontend.example.com" \
-H "Access-Control-Request-Method: GET" \
-v
Backup Database
docker cp captain--codesnippet-backend:/app/data/snippets.db ./backup-$(date +%Y%m%d).db
Troubleshooting Quick Fixes
Frontend can't connect to backend
- Check
VITE_FLASK_BACKEND_URLin frontend environment variables - Verify backend is running:
curl https://backend.example.com/health - Check CORS configuration in backend
CORS errors in browser
- Verify
CORS_ALLOWED_ORIGINSincludes frontend URL exactly - Ensure both use HTTPS (not mixed HTTP/HTTPS)
- Restart backend app after environment changes
SSL certificate issues
- Wait 5-10 minutes for Let's Encrypt
- Verify DNS records point to CapRover
- Disable and re-enable HTTPS in CapRover
Data lost after restart
- Verify "Has Persistent Data" enabled in backend app
- Check persistent directory path:
/app/data - Verify volume is mounted correctly
Environment Variables Quick Reference
Backend (codesnippet-backend)
CORS_ALLOWED_ORIGINS=https://frontend.example.com
DATABASE_PATH=/app/data/snippets.db
Frontend (codesnippet-frontend)
VITE_FLASK_BACKEND_URL=https://backend.example.com
Alternative: Single Domain Deployment
For single domain setup (https://app.example.com):
Backend
- Deploy backend (internal only, no custom domain)
- Set
CORS_ALLOWED_ORIGINS=*(not needed if proxied)
Frontend
- Set
VITE_FLASK_BACKEND_URL=/api - nginx proxies
/apito backend (already configured) - Deploy with custom domain:
app.example.com
Benefits: No CORS issues, simpler DNS Drawbacks: Tightly coupled services
Rollback Plan
If deployment fails:
- Frontend issues: Redeploy previous version
- Backend issues: Check logs, fix errors, redeploy
- Database corruption: Restore from backup
- DNS issues: Verify Cloudflare settings
- SSL issues: Disable HTTPS temporarily, debug, re-enable
Maintenance Schedule
- Daily: Check error logs
- Weekly: Review metrics and performance
- Monthly: Update dependencies, security patches
- Quarterly: Review and rotate secrets/keys