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 <sanjay@example.com>
This commit is contained in:
SANJAY
2026-06-14 17:32:43 -07:00
committed by GitHub
co-authored by sanjayravit
parent 48a2627c9a
commit 7ba334b5f0
+4 -3
View File
@@ -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();
}
}