Fix double /api/ — remove prefix from paths, request function adds it

This commit is contained in:
2026-04-26 11:39:53 -04:00
parent b696fd07a5
commit 4c8556a3d2
+15 -15
View File
@@ -12,30 +12,30 @@ async function request<T>(path: string, options?: RequestInit): Promise<T> {
}
export const api = {
getSettings: () => request<Settings>('/api/settings'),
getSettings: () => request<Settings>('/settings'),
updateSettings: (s: Partial<Settings>) =>
request<Settings>('/api/settings', { method: 'POST', body: JSON.stringify(s) }),
getConversations: () => request<Conversation[]>('/api/conversations'),
request<Settings>('/settings', { method: 'POST', body: JSON.stringify(s) }),
getConversations: () => request<Conversation[]>('/conversations'),
newConversation: (title = 'New conversation') =>
request<Conversation>('/api/conversations', { method: 'POST', body: JSON.stringify({ title }) }),
getMessages: (id: string) => request<Message[]>(`/api/conversations/${id}/messages`),
request<Conversation>('/conversations', { method: 'POST', body: JSON.stringify({ title }) }),
getMessages: (id: string) => request<Message[]>(`/conversations/${id}/messages`),
renameConversation: (id: string, title: string) =>
request<Conversation>(`/api/conversations/${id}`, { method: 'PATCH', body: JSON.stringify({ title }) }),
request<Conversation>(`/conversations/${id}`, { method: 'PATCH', body: JSON.stringify({ title }) }),
deleteConversation: (id: string) =>
request<{ deleted: string }>(`/api/conversations/${id}`, { method: 'DELETE' }),
request<{ deleted: string }>(`/conversations/${id}`, { method: 'DELETE' }),
clearAllConversations: () =>
request<{ cleared: boolean }>('/api/conversations', { method: 'DELETE' }),
request<{ cleared: boolean }>('/conversations', { method: 'DELETE' }),
sendMessage: (message: string, conversation_id: string) =>
request<ChatResponse>('/api/chat', { method: 'POST', body: JSON.stringify({ message, conversation_id }) }),
getMemory: () => request<{ content: string }>('/api/memory'),
request<ChatResponse>('/chat', { method: 'POST', body: JSON.stringify({ message, conversation_id }) }),
getMemory: () => request<{ content: string }>('/memory'),
updateMemory: (content: string) =>
request<{ saved: boolean }>('/api/memory', { method: 'POST', body: JSON.stringify({ content }) }),
getStatus: () => request<Status>('/api/status'),
reindex: () => request<{ started: boolean }>('/api/reindex', { method: 'POST' }),
request<{ saved: boolean }>('/memory', { method: 'POST', body: JSON.stringify({ content }) }),
getStatus: () => request<Status>('/status'),
reindex: () => request<{ started: boolean }>('/reindex', { method: 'POST' }),
transcribe: async (audio: Blob): Promise<{ text: string }> => {
const form = new FormData();
form.append('audio', audio, 'recording.webm');
const url = API_BASE ? `${API_BASE}/api/transcribe` : '/api/transcribe';
const url = '/api/transcribe';
const res = await fetch(url, { method: 'POST', credentials: 'include', body: form });
if (!res.ok) throw new Error(`Transcribe error: ${res.status}`);
return res.json();
@@ -46,7 +46,7 @@ export const api = {
if (data.image) form.append('image', data.image);
if (data.text) form.append('text', data.text);
if (data.project) form.append('project', data.project);
const url = API_BASE ? `${API_BASE}/api/capture` : '/api/capture';
const url = '/api/capture';
const res = await fetch(url, { method: 'POST', credentials: 'include', body: form });
if (!res.ok) throw new Error(`Capture error: ${res.status}`);
return res.json();