fix: charger team.html via fetch au lieu de redirection

Le reverse proxy redirige /team.html vers /team, créant une boucle.
Solution: fetch le contenu de team.html et l'injecter dans le DOM
avec document.write() pour remplacer complètement la page.
This commit is contained in:
syoul
2025-12-09 15:50:33 +01:00
parent e29b7401d6
commit 95ab0b68ae

View File

@@ -1,19 +1,40 @@
// SCRIPT ÉQUIPE - REDIRECTION VERS team.html
// SCRIPT ÉQUIPE - CHARGEMENT DYNAMIQUE DE team.html
(function() {
'use strict';
// DÉTECTION PAGE ÉQUIPE (mais PAS team.html)
var path = window.location.pathname;
var isTeamRoute = path === '/team' || path === '/team/' || path.startsWith('/team/');
var isTeamHtml = path === '/team.html';
if (isTeamRoute && !isTeamHtml) {
console.log('🔄 ÉQUIPE: Redirection vers /team.html');
window.location.replace('/team.html');
if (!isTeamRoute) {
return;
}
if (isTeamHtml) {
console.log('✅ ÉQUIPE: Page team.html chargée directement');
console.log('🔄 ÉQUIPE: Chargement du contenu team.html');
// Charger le contenu de team.html via fetch
function loadTeamContent() {
fetch('/team.html')
.then(function(response) {
if (!response.ok) throw new Error('HTTP ' + response.status);
return response.text();
})
.then(function(html) {
console.log('✅ ÉQUIPE: Contenu team.html chargé');
// Remplacer tout le document
document.open();
document.write(html);
document.close();
})
.catch(function(error) {
console.error('❌ ÉQUIPE: Erreur chargement:', error);
});
}
// Charger immédiatement
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', loadTeamContent);
} else {
loadTeamContent();
}
})();