fix: add CSRF token to streaming fetch request
This commit is contained in:
@@ -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 }),
|
||||||
|
|||||||
Reference in New Issue
Block a user