From 91b44e06adabb12be9087eeaa4a78ca5b1e23f13 Mon Sep 17 00:00:00 2001 From: Nicolas Cantu Date: Wed, 10 Sep 2025 18:27:11 +0200 Subject: [PATCH] fix: remove backend health check to prevent 404 errors - Remove unnecessary backend connectivity check in Layout component - Simplify Layout component by removing unused imports and state - Application now works seamlessly in demo mode without backend errors - Clean console output without 404 errors on startup --- src/components/Layout.tsx | 38 +------------------------------------- src/services/api.ts | 4 ++-- 2 files changed, 3 insertions(+), 39 deletions(-) diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx index d0cc81a..ed3ca1c 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout.tsx @@ -1,8 +1,7 @@ import React from 'react' -import { AppBar, Toolbar, Typography, Container, Box, Alert, Snackbar } from '@mui/material' +import { AppBar, Toolbar, Typography, Container, Box } from '@mui/material' import { useNavigate, useLocation } from 'react-router-dom' import { NavigationTabs } from './NavigationTabs' -import { useState, useEffect } from 'react' interface LayoutProps { children: React.ReactNode @@ -11,26 +10,6 @@ interface LayoutProps { export const Layout: React.FC = ({ children }) => { const navigate = useNavigate() const location = useLocation() - const [showDemoAlert, setShowDemoAlert] = useState(false) - - useEffect(() => { - // Vérifier si le backend est accessible - const checkBackend = async () => { - try { - const response = await fetch('http://localhost:8000/health', { - method: 'GET', - signal: AbortSignal.timeout(2000) - }) - if (!response.ok) { - setShowDemoAlert(true) - } - } catch (error) { - setShowDemoAlert(true) - } - } - - checkBackend() - }, []) return ( @@ -52,21 +31,6 @@ export const Layout: React.FC = ({ children }) => { {children} - - setShowDemoAlert(false)} - anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }} - > - setShowDemoAlert(false)} - severity="info" - sx={{ width: '100%' }} - > - Mode démonstration activé - Backend non accessible - - ) } diff --git a/src/services/api.ts b/src/services/api.ts index b618709..e68b586 100644 --- a/src/services/api.ts +++ b/src/services/api.ts @@ -13,7 +13,7 @@ apiClient.interceptors.response.use( (response) => response, (error) => { console.error('API Error:', error) - + // Gestion gracieuse des erreurs de connexion if (error.code === 'ERR_NETWORK' || error.code === 'ERR_CONNECTION_REFUSED') { console.warn('Backend non accessible, mode démo activé') @@ -29,7 +29,7 @@ apiClient.interceptors.response.use( } }) } - + return Promise.reject(error) } )