diff --git a/debug-production.js b/debug-production.js new file mode 100644 index 0000000..ca4dd3d --- /dev/null +++ b/debug-production.js @@ -0,0 +1,59 @@ +#!/usr/bin/env node + +// Script de diagnostic pour la production LogiFlow +// Usage: node debug-production.js [URL_BASE] + +const url = process.argv[2] || 'https://logiflow.ffnancy.fr'; + +const runDiagnostics = async () => { + console.log(`🔍 Diagnostic de production pour ${url}\n`); + + const endpoints = [ + { path: '/api/health', desc: 'Health Check' }, + { path: '/api/user', desc: 'API User (attendu: 401)' }, + { path: '/api/default-credentials-check', desc: 'Credentials Check' }, + { path: '/', desc: 'Page principale' }, + { path: '/sav', desc: 'Page SAV' } + ]; + + for (const endpoint of endpoints) { + try { + console.log(`📡 Test ${endpoint.desc}: ${url}${endpoint.path}`); + + const response = await fetch(`${url}${endpoint.path}`, { + method: 'GET', + headers: { + 'User-Agent': 'LogiFlow-Debug/1.0' + } + }); + + console.log(` Status: ${response.status} ${response.statusText}`); + + if (endpoint.path === '/api/health' && response.ok) { + const data = await response.json(); + console.log(` Détails:`, data); + } + + if (response.status === 502) { + console.log(` ❌ Erreur 502: Service indisponible ou problème de proxy`); + } else if (response.ok || response.status === 401) { + console.log(` ✅ Service répond correctement`); + } else { + console.log(` ⚠️ Status inattendu`); + } + + } catch (error) { + console.log(` ❌ Erreur de connexion: ${error.message}`); + } + + console.log(''); + } + + console.log('🔧 Actions recommandées:'); + console.log('1. Vérifier les logs Docker: docker-compose logs logiflow'); + console.log('2. Vérifier le status: docker-compose ps'); + console.log('3. Redémarrer si nécessaire: docker-compose restart logiflow'); + console.log('4. Forcer rebuild: docker-compose up --build -d'); +}; + +runDiagnostics().catch(console.error); \ No newline at end of file diff --git a/production-health-check.sh b/production-health-check.sh new file mode 100755 index 0000000..502f965 --- /dev/null +++ b/production-health-check.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# Script de vérification de santé pour LogiFlow en production +echo "🔍 Vérification de santé LogiFlow Production" +echo "==============================================" + +# Vérifier le status des containers +echo "📊 Status des containers:" +docker-compose ps + +echo "" +echo "🏥 Health checks:" +docker-compose exec logiflow wget --spider -q http://localhost:3000/api/health +if [ $? -eq 0 ]; then + echo "✅ Health check API OK" +else + echo "❌ Health check API FAILED" +fi + +# Vérifier les fichiers statiques +echo "" +echo "📁 Vérification des fichiers statiques:" +docker-compose exec logiflow ls -la /app/dist/public/ | head -10 + +# Test des endpoints critiques +echo "" +echo "🌐 Test des endpoints:" +echo "Health:" +curl -s -o /dev/null -w "Status: %{http_code}\n" https://logiflow.ffnancy.fr/api/health + +echo "Root:" +curl -s -o /dev/null -w "Status: %{http_code}\n" https://logiflow.ffnancy.fr/ + +echo "SAV:" +curl -s -o /dev/null -w "Status: %{http_code}\n" https://logiflow.ffnancy.fr/sav + +# Dernières logs +echo "" +echo "📋 Dernières logs (10 lignes):" +docker-compose logs --tail=10 logiflow + +echo "" +echo "🔧 Si erreur 502 persistent:" +echo " docker-compose restart logiflow" +echo " docker-compose up --build -d # Rebuild complet" \ No newline at end of file diff --git a/server/index.production.ts b/server/index.production.ts index 6b70bae..27f0d28 100644 --- a/server/index.production.ts +++ b/server/index.production.ts @@ -45,7 +45,9 @@ async function registerProductionRoutes(app: Express): Promise { status: 'healthy', timestamp: new Date().toISOString(), environment: 'production', - database: 'connected' + database: 'connected', + port: process.env.PORT || 3000, + publicPath: join(__dirname, 'public') }); }); @@ -180,12 +182,29 @@ console.log('🐳 Serving static files from:', publicPath); app.use('/assets', express.static(join(publicPath, 'assets'))); app.use('/', express.static(publicPath)); +// Add explicit root route handler +app.get('/', (req, res) => { + console.log('🏠 ROOT: Serving index.html for root request'); + res.sendFile(join(publicPath, 'index.html'), (err) => { + if (err) { + console.error('❌ ROOT: Error serving index.html:', err); + res.status(500).send('Error loading application'); + } + }); +}); + // SPA fallback - serve index.html for all non-API routes app.get('*', (req, res, next) => { if (req.path.startsWith('/api/')) { return next(); } - res.sendFile(join(publicPath, 'index.html')); + console.log(`📄 SPA: Serving index.html for ${req.path}`); + res.sendFile(join(publicPath, 'index.html'), (err) => { + if (err) { + console.error(`❌ SPA: Error serving index.html for ${req.path}:`, err); + res.status(500).send('Error loading application'); + } + }); }); const port = process.env.PORT ? parseInt(process.env.PORT) : 3000;