diff --git a/frontend/src/api/ai.ts b/frontend/src/api/ai.ts index dc69aed..1aba362 100644 --- a/frontend/src/api/ai.ts +++ b/frontend/src/api/ai.ts @@ -156,10 +156,12 @@ export async function* streamChat( content: string, agentId?: string ): AsyncGenerator { + const csrfToken = sessionStorage.getItem('leocrm_csrf_token'); const response = await fetch(`/api/v1/ai/sessions/${sessionId}/stream`, { method: 'POST', headers: { 'Content-Type': 'application/json', + ...(csrfToken ? { 'X-CSRF-Token': csrfToken } : {}), }, credentials: 'include', body: JSON.stringify({ content, agent_id: agentId }),