From: PhiTux Date: Sat, 16 Aug 2025 17:56:45 +0000 (+0200) Subject: fixed filename of export X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=124d348537aee34dbead1656f0c3a98c5264a9c9;p=DailyTxT.git fixed filename of export --- diff --git a/backend/handlers/additional.go b/backend/handlers/additional.go index 5920e0a..2eaed53 100644 --- a/backend/handlers/additional.go +++ b/backend/handlers/additional.go @@ -1630,7 +1630,7 @@ func ExportData(w http.ResponseWriter, r *http.Request) { } w.Header().Set("Content-Type", "application/zip") - w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filename)) + w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename)) // Create ZIP writer zipWriter := zip.NewWriter(w) diff --git a/backend/middleware/middleware.go b/backend/middleware/middleware.go index 704403c..7307233 100644 --- a/backend/middleware/middleware.go +++ b/backend/middleware/middleware.go @@ -28,7 +28,8 @@ func CORS(next http.Handler) http.Handler { if allowed { w.Header().Set("Access-Control-Allow-Origin", origin) w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS") - w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization") + w.Header().Set("Access-Control-Expose-Headers", "Content-Disposition") + w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization, Content-Disposition") w.Header().Set("Access-Control-Allow-Credentials", "true") } diff --git a/frontend/src/routes/(authed)/+layout.svelte b/frontend/src/routes/(authed)/+layout.svelte index 1afcc5c..e4a35f3 100644 --- a/frontend/src/routes/(authed)/+layout.svelte +++ b/frontend/src/routes/(authed)/+layout.svelte @@ -611,7 +611,17 @@ const url = window.URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; - a.download = `DailyTxT_Export_${localStorage.getItem('users')}.zip`; + + const contentDisposition = response.headers['content-disposition']; + let filename = 'DailyTxT_Export.zip'; + if (contentDisposition) { + const filenameMatch = contentDisposition.match(/filename="(.+)"/); + if (filenameMatch) { + filename = filenameMatch[1]; + } + } + + a.download = filename; document.body.appendChild(a); a.click(); a.remove();