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) {
|
if (!res.error) {
|
||||||
updateImages();
|
updateImages();
|
||||||
showNotification({
|
showNotification({
|
||||||
title: 'Image Deleted',
|
title: 'File Deleted',
|
||||||
message: '',
|
message: `${original.name}`,
|
||||||
color: 'green',
|
color: 'green',
|
||||||
icon: <DeleteIcon />,
|
icon: <DeleteIcon />,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
showNotification({
|
showNotification({
|
||||||
title: 'Failed to delete image',
|
title: 'Failed to Delete File',
|
||||||
message: res.error,
|
message: res.error,
|
||||||
color: 'red',
|
color: 'red',
|
||||||
icon: <CrossIcon />,
|
icon: <CrossIcon />,
|
||||||
|
@ -54,7 +54,11 @@ export default function Dashboard({ disableMediaPreview, exifEnabled }) {
|
||||||
clipboard.copy(`${window.location.protocol}//${window.location.host}${original.url}`);
|
clipboard.copy(`${window.location.protocol}//${window.location.host}${original.url}`);
|
||||||
showNotification({
|
showNotification({
|
||||||
title: 'Copied to clipboard',
|
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 />,
|
icon: <CopyIcon />,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { Image, PrismaClient } from '@prisma/client';
|
import { Image, PrismaClient } from '@prisma/client';
|
||||||
import Router from 'find-my-way';
|
import Router from 'find-my-way';
|
||||||
|
import { createReadStream, existsSync } from 'fs';
|
||||||
import { mkdir } from 'fs/promises';
|
import { mkdir } from 'fs/promises';
|
||||||
import { createServer, IncomingMessage, OutgoingMessage, ServerResponse } from 'http';
|
import { createServer, IncomingMessage, OutgoingMessage, ServerResponse } from 'http';
|
||||||
import next from 'next';
|
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) => {
|
router.on('GET', `${config.urls.route}/:id`, async (req, res, params) => {
|
||||||
if (params.id === '') return nextServer.render404(req, res as ServerResponse);
|
if (params.id === '') return nextServer.render404(req, res as ServerResponse);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue