diff --git a/.replit b/.replit index 30bea15..3e67b19 100644 --- a/.replit +++ b/.replit @@ -14,6 +14,10 @@ run = ["npm", "run", "start"] localPort = 5000 externalPort = 80 +[[ports]] +localPort = 34661 +externalPort = 3001 + [[ports]] localPort = 41303 externalPort = 3002 diff --git a/deployment/check_frontend.sh b/deployment/check_frontend.sh index b89fb79..8644a48 100644 --- a/deployment/check_frontend.sh +++ b/deployment/check_frontend.sh @@ -25,6 +25,11 @@ else # Wait a moment sleep 2 + # Load environment variables from .env file + set -a + source "$WORK_DIR/.env" 2>/dev/null || true + set +a + # Start frontend cd "$WORK_DIR" nohup npm run dev >> "$LOG_FILE" 2>&1 & diff --git a/replit.md b/replit.md index ea6ad98..ad1a87d 100644 --- a/replit.md +++ b/replit.md @@ -43,6 +43,19 @@ Sistema di rilevamento intrusioni per router MikroTik basato su Machine Learning ## Fix Recenti (Novembre 2025) +### ✅ Frontend Environment Variables Fix (21 Nov 2025 - 16:30) +- **Problema**: Frontend Node.js non si avviava su server AlmaLinux con errore `DATABASE_URL must be set` +- **Causa**: Script `check_frontend.sh` non caricava variabili d'ambiente dal file `.env` +- **Soluzione**: + - Modificato `deployment/check_frontend.sh` per caricare `.env` prima di eseguire `npm run dev` + - Usato `set -a; source .env; set +a` per esportare tutte le variabili +- **Risultato**: Frontend si avvia correttamente leggendo `DATABASE_URL` e altre variabili da `.env` + +### ✅ Form Validation Migliorata (21 Nov 2025 - 15:00) +- **API ML Endpoints**: Timeout configurabili (120s train/detect, 10s stats), validazione input, messaggi errore specifici (504 timeout, 503 backend down, 400 validation) +- **Whitelist Form**: Convertito a react-hook-form + zodResolver, validazione IP completa (regex + controllo ottetti 0-255) +- **Training Forms**: Due form separati (trainForm/detectForm), schema Zod con z.coerce.number(), FormDescription per suggerimenti + ### ✅ Sistema Completamente Funzionante (17 Nov 2025 - 19:30) - **Backend Python FastAPI**: ✅ Porta 8000, modello ML caricato, endpoint /stats funzionante - **Database PostgreSQL**: ✅ 5 tabelle (network_logs, detections, routers, whitelist, training_history)