fix: pass auth token via query param for SSE EventSource

EventSource API doesn't support custom headers, so pass token as
?token= query parameter. Server auth middleware now accepts token
from both Authorization header and query param.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ekko
2026-04-15 09:13:27 +08:00
parent 29f19ddb30
commit 62e0d6fbed
3 changed files with 7 additions and 4 deletions
+3 -2
View File
@@ -1,4 +1,4 @@
import { request, getBaseUrlValue } from './client'
import { request, getBaseUrlValue, getApiKey } from './client'
export interface ChatMessage {
role: 'user' | 'assistant' | 'system'
@@ -44,7 +44,8 @@ export function streamRunEvents(
onError: (err: Error) => void,
) {
const baseUrl = getBaseUrlValue()
const url = `${baseUrl}/v1/runs/${runId}/events`
const token = getApiKey()
const url = `${baseUrl}/v1/runs/${runId}/events${token ? `?token=${encodeURIComponent(token)}` : ''}`
let closed = false
const source = new EventSource(url)