GET /favicon.ico should not load parent app

Cette révision appartient à :
AJ ONeal 2015-02-23 20:35:32 +00:00
Parent 045955b29e
révision fcc8e232dc
3 fichiers modifiés avec 33 ajouts et 3 suppressions

Voir le fichier

@ -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 {

Voir le fichier

@ -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",

BIN
public/favicon.ico Fichier normal

Fichier binaire non affiché.

Après

Largeur:  |  Hauteur:  |  Taille: 198 B