use res.download to download flyer

This commit is contained in:
lesion
2022-09-05 13:03:35 +02:00
parent e8ed2ec4b0
commit 81c2bd3dd1
3 changed files with 8 additions and 4 deletions

View File

@@ -91,6 +91,9 @@ module.exports = {
const router = express.Router()
// serve images/thumb
router.use('/media/', express.static(config.upload_path, { immutable: true, maxAge: '1y' }), (_req, res) => res.sendStatus(404))
router.use('/download/:filename', (req, res, next) => {
return res.download(req.params.filename, undefined, { root: config.upload_path }, err => res.status(404).send('Not found (but nice try 😊)'))
})
router.use('/noimg.svg', express.static('./static/noimg.svg'))
router.use('/logo.png', (req, res, next) => {