mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-12 03:05:12 +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;
|
||||
}
|
||||
|
||||
// whatever happens, we're going to serve some HTML
|
||||
res.set({
|
||||
'Content-Type': 'text/html'
|
||||
});
|
||||
|
||||
try {
|
||||
for (const route of routes) {
|
||||
if (route.test(url)) {
|
||||
@@ -68,10 +73,6 @@ module.exports = function connect(opts) {
|
||||
});
|
||||
|
||||
res.status(200);
|
||||
res.set({
|
||||
// TODO etag stuff
|
||||
'Content-Type': 'text/html'
|
||||
});
|
||||
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) {
|
||||
// TODO nice error pages
|
||||
res.status(500);
|
||||
|
||||
Reference in New Issue
Block a user