From 8eb0383d488b5a0ca54f9e247819014e7b84d62d Mon Sep 17 00:00:00 2001 From: faligam Date: Sun, 6 Sep 2026 17:23:11 +0200 Subject: [PATCH] Fix API-key login and research navigation Validate submitted keys against the protected research endpoint instead of the nonexistent versioned health path. Replace server-only redirects in client code with SvelteKit navigation and route successful logins to the existing new-research screen. Align frontend research history and creation calls with the backend response contract: list items are wrapped in items and new runs return research_id. --- src/lib/sidebar.ts | 9 +++++---- src/routes/+page.svelte | 13 +++++++------ src/routes/research/new/+page.svelte | 3 +-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/lib/sidebar.ts b/src/lib/sidebar.ts index 3e1bc8f..a8f6536 100644 --- a/src/lib/sidebar.ts +++ b/src/lib/sidebar.ts @@ -16,7 +16,8 @@ export interface ResearchListItem extends ResearchSummary { const HISTORY_LIMIT = 50; export async function loadResearchHistory(apiKey: string): Promise { - const list = await apiGet('/v1/research', { apiKey }); + const response = await apiGet<{ items: ResearchSummary[] }>('/v1/research', { apiKey }); + const list = response.items; // Sort descending by created_at (newest first), limit to HISTORY_LIMIT const sorted = list .slice() @@ -34,10 +35,10 @@ export async function createResearch( query: string, language: string, depth: string -): Promise<{ id: string }> { - return await apiPost<{ id: string }>( +): Promise<{ research_id: string }> { + return await apiPost<{ research_id: string }>( '/v1/research', { query, language, depth }, { apiKey } ); -} \ No newline at end of file +} diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 3056bba..fe44e98 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,5 +1,5 @@