Update startup script to load environment variables correctly
Modify `deployment/check_frontend.sh` to source the `.env` file before starting the Node.js development server. This ensures that environment variables, such as `DATABASE_URL`, are properly loaded, resolving startup errors on non-Replit environments. Also updates `replit.md` to document this fix. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 21e2b3ab-3e67-45ff-819b-a2db15c27292 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/dI1I79r
This commit is contained in:
parent
b3bbcb69d3
commit
d0683b363f
4
.replit
4
.replit
@ -14,6 +14,10 @@ run = ["npm", "run", "start"]
|
||||
localPort = 5000
|
||||
externalPort = 80
|
||||
|
||||
[[ports]]
|
||||
localPort = 34661
|
||||
externalPort = 3001
|
||||
|
||||
[[ports]]
|
||||
localPort = 41303
|
||||
externalPort = 3002
|
||||
|
||||
@ -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 &
|
||||
|
||||
13
replit.md
13
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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user