From 419071b4c5233dc80e00c01e9cbc96030b7c54d8 Mon Sep 17 00:00:00 2001 From: Jules Neny Date: Thu, 7 May 2026 02:26:54 +0200 Subject: [PATCH] =?UTF-8?q?fix(chatbot):=20double-s=C3=A9curit=C3=A9=20end?= =?UTF-8?q?point=20=E2=80=94=20prop=20+=20useRoute=20fallback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Route /agences → /api/chatbot-reseaux garanti, même si prop non reçu. Titre du chatbot affiche la carte active pour confirmation visuelle. activeEndpoint computed depuis props.endpoint ?? route-based detection. Co-Authored-By: Claude Sonnet 4.6 --- components/ChatbotSheet.vue | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/components/ChatbotSheet.vue b/components/ChatbotSheet.vue index 94ea6a1..344ec58 100644 --- a/components/ChatbotSheet.vue +++ b/components/ChatbotSheet.vue @@ -61,7 +61,9 @@ - {{ props.title ?? 'Chatbot' }} + + {{ props.title ?? (activeEndpoint === '/api/chatbot-reseaux' ? 'Réseaux AEP' : 'Chatbot') }} + @@ -168,6 +170,14 @@ import { useMarkdown } from '~/composables/useMarkdown' const { render: renderMd } = useMarkdown() +// Détection double-sécurité : prop endpoint > route-based fallback +const route = useRoute() +const activeEndpoint = computed(() => { + if (props.endpoint) return props.endpoint + if (route.path.startsWith('/agences')) return '/api/chatbot-reseaux' + return '/api/chatbot' +}) + interface FicheReco { id: number | string nom: string @@ -232,7 +242,7 @@ async function sendMessage() { const res = await $fetch<{ reponse_texte: string fiches_recommandees: { id: number | string; nom: string; explication: string }[] - }>(props.endpoint ?? '/api/chatbot', { + }>(activeEndpoint.value, { method: 'POST', body: { question }, })