diff --git a/lib/vhost-sni-server.js b/lib/vhost-sni-server.js index 0704caf..e88b7b0 100644 --- a/lib/vhost-sni-server.js +++ b/lib/vhost-sni-server.js @@ -6,6 +6,7 @@ module.exports.create = function (securePort, certsPath, vhostsdir) { var fs = require('fs'); var path = require('path'); var dummyCerts; + var serveFavicon; var secureContexts = {}; function loadDummyCerts() { @@ -98,9 +99,37 @@ module.exports.create = function (securePort, certsPath, vhostsdir) { function localAppWrapped(req, res) { console.log('[debug]', domaininfo.hostname + '/' + domaininfo.pathname, req.url); localApp(req, res, function (err) { - res.end('{ "error": { "messages": "Route matched ' - + domaininfo.hostname + '/' + domaininfo.pathname - + ', but was not handled. Forcing hard stop to prevent fallthru." } }'); + if (!serveFavicon) { + serveFavicon = require('serve-favicon')(path.join(__dirname, '..', 'public', 'favicon.ico')); + } + + // TODO redirect GET /favicon.ico to GET (req.headers.referer||'') + /favicon.ico + // TODO other common root things - robots.txt, app-icon, etc + serveFavicon(req, res, function (err2) { + res.writeHead(404); + res.end( + "" + + "" + + '' + + "" + + "" + + "Cannot " + + req.method + + " '" + + domaininfo.hostname + + '/' + + (domaininfo.pathname ? (domaininfo.pathname + '/') : '') + + req.url.replace(/^\//, '') + + "'" + + "" + + "" + ); + /* + res.end('{ "error": { "messages": "Route matched ' + + domaininfo.hostname + '/' + domaininfo.pathname + + ', but was not handled. Forcing hard stop to prevent fallthru." } }'); + */ + }); }); } try { diff --git a/package.json b/package.json index 1b55663..4b60f4c 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "nat-pmp": "0.0.3", "node-acme": "0.0.1", "request": "^2.53.0", + "serve-favicon": "^2.2.0", "serve-index": "^1.6.2", "serve-static": "^1.9.1", "ssl-root-cas": "^1.1.7", diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..85a4d9f Binary files /dev/null and b/public/favicon.ico differ