mirror of
https://github.com/complexcaresolutions/dak.c2s.git
synced 2026-03-17 16:03:41 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
parent
dbb5afaeb9
commit
4cd52dd0b2
1 changed files with 2 additions and 3 deletions
|
|
@ -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')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue