update
This commit is contained in:
28
server.js
28
server.js
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user