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.
This commit is contained in:
@@ -16,7 +16,8 @@ export interface ResearchListItem extends ResearchSummary {
|
||||
const HISTORY_LIMIT = 50;
|
||||
|
||||
export async function loadResearchHistory(apiKey: string): Promise<ResearchSummary[]> {
|
||||
const list = await apiGet<ResearchSummary[]>('/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 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user