diff --git a/packages/cli/src/tui/hooks/use-conversations.ts b/packages/cli/src/tui/hooks/use-conversations.ts index 0855eca..50078f7 100644 --- a/packages/cli/src/tui/hooks/use-conversations.ts +++ b/packages/cli/src/tui/hooks/use-conversations.ts @@ -31,18 +31,22 @@ export function useConversations(opts: UseConversationsOptions): UseConversation const [error, setError] = useState(null); const mountedRef = useRef(true); - const headers = useCallback((): Record => { - const h: Record = { 'Content-Type': 'application/json' }; - if (sessionCookie) h['Cookie'] = sessionCookie; - return h; - }, [sessionCookie]); + const headers = useCallback( + (includeContentType = true): Record => { + const h: Record = { Origin: gatewayUrl }; + if (includeContentType) h['Content-Type'] = 'application/json'; + if (sessionCookie) h['Cookie'] = sessionCookie; + return h; + }, + [gatewayUrl, sessionCookie], + ); const refresh = useCallback(async () => { if (!mountedRef.current) return; setLoading(true); setError(null); try { - const res = await fetch(`${gatewayUrl}/api/conversations`, { headers: headers() }); + const res = await fetch(`${gatewayUrl}/api/conversations`, { headers: headers(false) }); if (!res.ok) throw new Error(`HTTP ${res.status}`); const data = (await res.json()) as ConversationSummary[]; if (mountedRef.current) { @@ -93,7 +97,7 @@ export function useConversations(opts: UseConversationsOptions): UseConversation try { const res = await fetch(`${gatewayUrl}/api/conversations/${id}`, { method: 'DELETE', - headers: headers(), + headers: headers(false), }); if (!res.ok) return false; if (mountedRef.current) {