This commit is contained in:
lesion
2022-09-13 09:06:40 +02:00
parent 33fe97bff3
commit d4cf41f8da

View File

@@ -91,8 +91,12 @@ 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('/download/:filename', (req, res) => {
return res.download(req.params.filename, undefined, { root: config.upload_path }, err => {
if (err) {
res.status(404).send('Not found (but nice try 😊)')
}
})
})
router.use('/noimg.svg', express.static('./static/noimg.svg'))