This commit is contained in:
sebseb7
2025-11-23 11:45:42 +01:00
parent 71910f84a2
commit 68cc98cfd4
11 changed files with 116 additions and 100 deletions

View File

@@ -0,0 +1,17 @@
import path from 'path';
export function registerImages(app, cacheDir) {
app.get('/img/cat/:id.avif', (req, res) => {
const { id } = req.params;
const imagePath = path.join(cacheDir, 'img', 'categories', `${id}.avif`);
// Cache images for 1 year (immutable content)
res.set('Cache-Control', 'public, max-age=31536000, immutable');
res.sendFile(path.resolve(imagePath), (err) => {
if (err) {
res.status(404).send('Image not found');
}
});
});
}