From 7ba334b5f020bd8f5ff6ea3e57ae397c19994a6c Mon Sep 17 00:00:00 2001 From: SANJAY Date: Mon, 15 Jun 2026 06:02:43 +0530 Subject: [PATCH] fix(gui): inject bearer token into streaming chat/research routes (#499) Ensures that the desktop GUI correctly sends the Authorization header when an API key is configured. This resolves the 'Failed to get response' bug on Windows systems with enabled authentication. Ref: #266 Co-authored-by: sanjayravit --- frontend/src/lib/sse.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/sse.ts b/frontend/src/lib/sse.ts index ffe7baff..7d5933ea 100644 --- a/frontend/src/lib/sse.ts +++ b/frontend/src/lib/sse.ts @@ -1,5 +1,5 @@ import type { ResearchEvent, SSEEvent } from '../types'; -import { getBase } from './api'; +import { getBase, authHeaders } from './api'; export interface ChatRequest { model: string; @@ -16,7 +16,7 @@ export async function* streamChat( const base = getBase(); const response = await fetch(`${base}/v1/chat/completions`, { method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: authHeaders({ 'Content-Type': 'application/json' }), body: JSON.stringify(request), signal, }); @@ -67,7 +67,7 @@ export async function* streamResearch( const base = getBase().replace(/\/v1\/?$/, ''); const response = await fetch(`${base}/api/research`, { method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: authHeaders({ 'Content-Type': 'application/json' }), body: JSON.stringify({ query }), signal, }); @@ -106,3 +106,4 @@ export async function* streamResearch( reader.releaseLock(); } } +