From 4cd52dd0b2ebe5f28ed15b759868deff6bf7b5ea Mon Sep 17 00:00:00 2001 From: CCS Admin Date: Thu, 26 Feb 2026 23:10:12 +0000 Subject: [PATCH] fix: correct double /api/ prefix in report download URL The download function used `/api/reports/download/{id}` as the URL for the axios instance which already has `baseURL: '/api'`. This resulted in requests to `/api/api/reports/download/{id}`, causing nginx to serve the SPA index.html (status 200, text/html) instead of proxying to the backend. The HTML was then saved as .xlsx, making Excel unable to open it. Fix: Use `/reports/download/{id}` for axios (which prepends baseURL) and keep the full `/api/reports/download/{id}` for the window.open fallback. Co-Authored-By: Claude Opus 4.6 --- frontend/src/pages/ReportsPage.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/ReportsPage.tsx b/frontend/src/pages/ReportsPage.tsx index 8306993..be1caf3 100644 --- a/frontend/src/pages/ReportsPage.tsx +++ b/frontend/src/pages/ReportsPage.tsx @@ -54,8 +54,7 @@ export function ReportsPage() { const downloadReport = (reportId: number) => { const token = localStorage.getItem('access_token') - const url = `/api/reports/download/${reportId}` - api.get(url, { responseType: 'blob' }) + api.get(`/reports/download/${reportId}`, { responseType: 'blob' }) .then((res) => { const blob = new Blob([res.data as BlobPart], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', @@ -77,7 +76,7 @@ export function ReportsPage() { }) .catch(() => { if (token) { - window.open(`${url}?token=${encodeURIComponent(token)}`, '_blank') + window.open(`/api/reports/download/${reportId}?token=${encodeURIComponent(token)}`, '_blank') } }) }