diff --git a/public/strategie-script.js b/public/strategie-script.js index 212ca1f..ee57859 100644 --- a/public/strategie-script.js +++ b/public/strategie-script.js @@ -1,8 +1,50 @@ // Script pour la gestion des pages de stratégie (function() { - // Protection contre Fast Refresh : éviter les modifications DOM pendant le hot-reload - if (window.__NEXT_DATA__ && window.__NEXT_DATA__.page === '/_error') { - return; // Ne pas exécuter pendant les erreurs de rechargement + // Protection contre Fast Refresh : ignorer les tentatives de hot-reload + // Intercepter et ignorer les requêtes webpack hot-update pour éviter les rechargements en boucle + if (typeof window !== 'undefined') { + // Intercepter fetch + const originalFetch = window.fetch; + window.fetch = function(...args) { + const url = args[0]; + if (typeof url === 'string' && url.includes('webpack.hot-update.json')) { + // Ignorer silencieusement les requêtes webpack hot-update + return Promise.resolve(new Response(JSON.stringify({}), { + status: 200, + headers: { 'Content-Type': 'application/json' } + })); + } + return originalFetch.apply(this, args); + }; + + // Intercepter XMLHttpRequest (utilisé par Next.js pour Fast Refresh) + const originalXHROpen = XMLHttpRequest.prototype.open; + XMLHttpRequest.prototype.open = function(method, url, ...rest) { + if (typeof url === 'string' && url.includes('webpack.hot-update.json')) { + // Créer un faux XHR qui ne fait rien + this._shouldIgnore = true; + return; + } + return originalXHROpen.apply(this, [method, url, ...rest]); + }; + + const originalXHRSend = XMLHttpRequest.prototype.send; + XMLHttpRequest.prototype.send = function(...args) { + if (this._shouldIgnore) { + // Simuler une réponse réussie pour éviter les erreurs + setTimeout(() => { + if (this.onload) this.onload(); + if (this.onreadystatechange) { + this.readyState = 4; + this.status = 200; + this.responseText = '{}'; + this.onreadystatechange(); + } + }, 0); + return; + } + return originalXHRSend.apply(this, args); + }; } // --- DÉBUT PROTECTION MOT DE PASSE --- diff --git a/scripts/start-business.sh b/scripts/start-business.sh index c66ccc9..8d75dcb 100644 --- a/scripts/start-business.sh +++ b/scripts/start-business.sh @@ -5,6 +5,8 @@ export HUSKY=0 export HUSKY_SKIP_INSTALL=1 export NODE_PATH=/app/node_modules export NODE_ENV=development +# Désactiver Fast Refresh pour éviter les rechargements en boucle +export NEXT_DISABLE_FAST_REFRESH=1 npm run serve -- --port "${PORT:-3000}"