This commit is contained in:
2025-12-13 20:46:48 +01:00
parent d874cec644
commit 9dc66b02fa
7 changed files with 279 additions and 26 deletions

View File

@@ -201,6 +201,34 @@ app.delete('/api/photos/:id', async (req, res) => {
// Serve Uploads
app.use('/uploads', express.static(UPLOAD_DIR));
// Favicon Storage
const faviconStorage = multer.diskStorage({
destination: (req, file, cb) => {
cb(null, UPLOAD_DIR);
},
filename: (req, file, cb) => {
cb(null, 'favicon.png');
}
});
const uploadFavicon = multer({ storage: faviconStorage });
// Upload Favicon
app.post('/api/favicon', uploadFavicon.single('favicon'), (req, res) => {
if (!req.file) return res.status(400).json({ error: 'No file uploaded' });
res.json({ success: true, url: '/uploads/favicon.png' });
});
// Serve Favicon (Dynamic)
app.get('/api/favicon', (req, res) => {
const faviconPath = path.join(UPLOAD_DIR, 'favicon.png');
if (fs.existsSync(faviconPath)) {
res.sendFile(faviconPath);
} else {
// Fallback to default
res.status(404).send('Not found');
}
});
// Serve Frontend (Production)
const DIST_DIR = path.join(__dirname, 'dist');
if (fs.existsSync(DIST_DIR)) {