From 9bc8e2084ad4a16efae07478b185fba87982f84d Mon Sep 17 00:00:00 2001 From: richardtekula Date: Fri, 30 Jan 2026 08:42:02 +0100 Subject: [PATCH] fix: Add explicit Content-Type and Content-Disposition headers for downloads Improves browser compatibility for PDF file downloads by setting proper MIME type and filename encoding. Co-Authored-By: Claude Opus 4.5 --- src/controllers/ai-kurzy.controller.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/controllers/ai-kurzy.controller.js b/src/controllers/ai-kurzy.controller.js index 71a3727..9b90ebd 100644 --- a/src/controllers/ai-kurzy.controller.js +++ b/src/controllers/ai-kurzy.controller.js @@ -247,6 +247,11 @@ export const downloadPriloha = async (req, res, next) => { return res.status(404).json({ success: false, error: { message: 'Súbor nenájdený na serveri' } }); } + // Set explicit headers for better browser compatibility + const mimeType = priloha.mimeType || 'application/octet-stream'; + res.setHeader('Content-Type', mimeType); + res.setHeader('Content-Disposition', `attachment; filename="${encodeURIComponent(priloha.nazovSuboru)}"`); + res.download(priloha.cestaKSuboru, priloha.nazovSuboru); } catch (error) { next(error);