diff --git a/frontend/src/api/client.ts b/frontend/src/api/client.ts index 786f650c0..f5788aff5 100644 --- a/frontend/src/api/client.ts +++ b/frontend/src/api/client.ts @@ -2062,9 +2062,13 @@ export const api = { getPrinterFileDownloadUrl: (printerId: number, path: string) => `${API_BASE}/printers/${printerId}/files/download?path=${encodeURIComponent(path)}`, downloadPrinterFilesAsZip: async (printerId: number, paths: string[]): Promise => { + const headers: Record = { 'Content-Type': 'application/json' }; + if (authToken) { + headers['Authorization'] = `Bearer ${authToken}`; + } const response = await fetch(`${API_BASE}/printers/${printerId}/files/download-zip`, { method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers, body: JSON.stringify({ paths }), }); if (!response.ok) { @@ -2173,7 +2177,11 @@ export const api = { if (options?.dateTo) params.set('date_to', options.dateTo); if (options?.search) params.set('search', options.search); - const response = await fetch(`${API_BASE}/archives/export?${params}`); + const headers: Record = {}; + if (authToken) { + headers['Authorization'] = `Bearer ${authToken}`; + } + const response = await fetch(`${API_BASE}/archives/export?${params}`, { headers }); if (!response.ok) { const error = await response.json().catch(() => ({})); throw new Error(error.detail || `HTTP ${response.status}`); @@ -2201,7 +2209,11 @@ export const api = { if (options?.printerId) params.set('printer_id', String(options.printerId)); if (options?.projectId) params.set('project_id', String(options.projectId)); - const response = await fetch(`${API_BASE}/archives/stats/export?${params}`); + const headers: Record = {}; + if (authToken) { + headers['Authorization'] = `Bearer ${authToken}`; + } + const response = await fetch(`${API_BASE}/archives/stats/export?${params}`, { headers }); if (!response.ok) { const error = await response.json().catch(() => ({})); throw new Error(error.detail || `HTTP ${response.status}`); @@ -3945,7 +3957,11 @@ export const supportApi = { }), downloadSupportBundle: async () => { - const response = await fetch(`${API_BASE}/support/bundle`); + const headers: Record = {}; + if (authToken) { + headers['Authorization'] = `Bearer ${authToken}`; + } + const response = await fetch(`${API_BASE}/support/bundle`, { headers }); if (!response.ok) { const error = await response.json().catch(() => ({})); throw new Error(error.detail || `HTTP ${response.status}`);