fix: serve favicon.ico always
This commit is contained in:
parent
a402227c4f
commit
577195b578
2 changed files with 18 additions and 4 deletions
|
@ -35,14 +35,14 @@ export default function Dashboard({ disableMediaPreview, exifEnabled }) {
|
|||
if (!res.error) {
|
||||
updateImages();
|
||||
showNotification({
|
||||
title: 'Image Deleted',
|
||||
message: '',
|
||||
title: 'File Deleted',
|
||||
message: `${original.name}`,
|
||||
color: 'green',
|
||||
icon: <DeleteIcon />,
|
||||
});
|
||||
} else {
|
||||
showNotification({
|
||||
title: 'Failed to delete image',
|
||||
title: 'Failed to Delete File',
|
||||
message: res.error,
|
||||
color: 'red',
|
||||
icon: <CrossIcon />,
|
||||
|
@ -54,7 +54,11 @@ export default function Dashboard({ disableMediaPreview, exifEnabled }) {
|
|||
clipboard.copy(`${window.location.protocol}//${window.location.host}${original.url}`);
|
||||
showNotification({
|
||||
title: 'Copied to clipboard',
|
||||
message: '',
|
||||
message: (
|
||||
<a
|
||||
href={`${window.location.protocol}//${window.location.host}${original.url}`}
|
||||
>{`${window.location.protocol}//${window.location.host}${original.url}`}</a>
|
||||
),
|
||||
icon: <CopyIcon />,
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Image, PrismaClient } from '@prisma/client';
|
||||
import Router from 'find-my-way';
|
||||
import { createReadStream, existsSync } from 'fs';
|
||||
import { mkdir } from 'fs/promises';
|
||||
import { createServer, IncomingMessage, OutgoingMessage, ServerResponse } from 'http';
|
||||
import next from 'next';
|
||||
|
@ -84,6 +85,15 @@ async function start() {
|
|||
},
|
||||
});
|
||||
|
||||
router.on('GET', '/favicon.ico', async (req, res) => {
|
||||
if (!existsSync('./public/favicon.ico')) return nextServer.render404(req, res);
|
||||
|
||||
const favicon = createReadStream('./public/favicon.ico');
|
||||
res.setHeader('Content-Type', 'image/x-icon');
|
||||
|
||||
favicon.pipe(res);
|
||||
});
|
||||
|
||||
router.on('GET', `${config.urls.route}/:id`, async (req, res, params) => {
|
||||
if (params.id === '') return nextServer.render404(req, res as ServerResponse);
|
||||
|
||||
|
|
Loading…
Reference in a new issue