mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 04:09:12 +00:00
don't redirect on 404 in build
This commit is contained in:
@@ -288,12 +288,18 @@ if (isDeveloping) {
|
||||
callbacks: {
|
||||
ready: (_err, instance) => {
|
||||
// 404 errors
|
||||
instance.addMiddleware('*', (req, res) => {
|
||||
instance.addMiddleware('*', async (req, res) => {
|
||||
if (req.url.toLowerCase().endsWith('.svg')) {
|
||||
// Make sure SVGs error out in dev instead of serve the 404 page
|
||||
res.writeHead(404);
|
||||
} else {
|
||||
res.writeHead(302, { location: '/404.html' });
|
||||
try {
|
||||
const notFoundTemplate = await readFile(join(siteDir, '404.html'), 'utf-8');
|
||||
res.writeHead(404);
|
||||
res.write(notFoundTemplate || 'Page Not Found');
|
||||
} catch {
|
||||
// We're probably disconnected for some reason, so fail gracefully
|
||||
}
|
||||
}
|
||||
|
||||
res.end();
|
||||
|
||||
Reference in New Issue
Block a user