mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-20 14:25:07 +00:00
serve 404 pages etc
This commit is contained in:
14
connect.js
14
connect.js
@@ -45,6 +45,11 @@ module.exports = function connect(opts) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// whatever happens, we're going to serve some HTML
|
||||||
|
res.set({
|
||||||
|
'Content-Type': 'text/html'
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (const route of routes) {
|
for (const route of routes) {
|
||||||
if (route.test(url)) {
|
if (route.test(url)) {
|
||||||
@@ -68,10 +73,6 @@ module.exports = function connect(opts) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
res.status(200);
|
res.status(200);
|
||||||
res.set({
|
|
||||||
// TODO etag stuff
|
|
||||||
'Content-Type': 'text/html'
|
|
||||||
});
|
|
||||||
res.end(page);
|
res.end(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +98,10 @@ module.exports = function connect(opts) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
res.status(404).end(templates.render(404, {
|
||||||
|
status: 404,
|
||||||
|
url
|
||||||
|
}));
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
// TODO nice error pages
|
// TODO nice error pages
|
||||||
res.status(500);
|
res.status(500);
|
||||||
|
|||||||
Reference in New Issue
Block a user