p
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user