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 <noreply@anthropic.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user