fix(chatbot): double-sécurité endpoint — prop + useRoute fallback
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 <noreply@anthropic.com>
This commit is contained in:
@@ -61,7 +61,9 @@
|
||||
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="font-bold text-sm" style="color: var(--nav-text);">{{ props.title ?? 'Chatbot' }}</span>
|
||||
<span class="font-bold text-sm" style="color: var(--nav-text);">
|
||||
{{ props.title ?? (activeEndpoint === '/api/chatbot-reseaux' ? 'Réseaux AEP' : 'Chatbot') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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 },
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user