GET /favicon.ico should not load parent app
This commit is contained in:
parent
045955b29e
commit
fcc8e232dc
|
@ -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(
|
||||
"<html>"
|
||||
+ "<head>"
|
||||
+ '<link rel="icon" href="favicon.ico" />'
|
||||
+ "</head>"
|
||||
+ "<body>"
|
||||
+ "Cannot "
|
||||
+ req.method
|
||||
+ " '"
|
||||
+ domaininfo.hostname
|
||||
+ '/'
|
||||
+ (domaininfo.pathname ? (domaininfo.pathname + '/') : '')
|
||||
+ req.url.replace(/^\//, '')
|
||||
+ "'"
|
||||
+ "</body>"
|
||||
+ "</html>"
|
||||
);
|
||||
/*
|
||||
res.end('{ "error": { "messages": "Route matched '
|
||||
+ domaininfo.hostname + '/' + domaininfo.pathname
|
||||
+ ', but was not handled. Forcing hard stop to prevent fallthru." } }');
|
||||
*/
|
||||
});
|
||||
});
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -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",
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 198 B |
Loading…
Reference in New Issue