This commit is contained in:
2026-02-19 11:49:56 +01:00
parent c718f15f09
commit 581e726f78
2 changed files with 15 additions and 5 deletions

View File

@@ -145,10 +145,9 @@ class KIChat {
this.isTyping = true;
try {
// Use relative path that works from any page location
const basePath = window.location.pathname.includes('/') ?
window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1) : '/';
// Build absolute URL to ensure correct path on any hosting
const apiUrl = new URL('/scripts/add/send.php', window.location.origin).href;
console.log('KI Chat: Sending to', apiUrl);
const response = await fetch(apiUrl, {
method: 'POST',
@@ -163,11 +162,14 @@ class KIChat {
})
});
console.log('KI Chat: Response status', response.status);
const data = await response.json();
console.log('KI Chat: Response data', data);
if (data.success) {
if (data.success && data.data && data.data.ai_response) {
this.addMessage('ki', data.data.ai_response, data.data.timestamp);
} else {
console.error('KI Chat: Invalid response structure', data);
this.addMessage('ki', 'Entschuldigung, es gab ein Problem. Bitte versuchen Sie es später erneut.');
}
} catch (error) {