fix: add CSRF token to streaming fetch request

This commit is contained in:
Agent Zero
2026-07-17 01:43:52 +02:00
parent 561d1919f5
commit da8d0ce818
+2
View File
@@ -156,10 +156,12 @@ export async function* streamChat(
content: string, content: string,
agentId?: string agentId?: string
): AsyncGenerator<StreamEvent> { ): AsyncGenerator<StreamEvent> {
const csrfToken = sessionStorage.getItem('leocrm_csrf_token');
const response = await fetch(`/api/v1/ai/sessions/${sessionId}/stream`, { const response = await fetch(`/api/v1/ai/sessions/${sessionId}/stream`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
...(csrfToken ? { 'X-CSRF-Token': csrfToken } : {}),
}, },
credentials: 'include', credentials: 'include',
body: JSON.stringify({ content, agent_id: agentId }), body: JSON.stringify({ content, agent_id: agentId }),