Fixed over-matching of index route.
This commit is contained in:
parent
ddcd05cbc2
commit
62e1225dd3
@ -23,8 +23,20 @@ InsightUI.dependencies = ['insight-api'];
|
|||||||
inherits(InsightUI, BaseService);
|
inherits(InsightUI, BaseService);
|
||||||
|
|
||||||
InsightUI.prototype.start = function(callback) {
|
InsightUI.prototype.start = function(callback) {
|
||||||
this.indexFile = this.filterIndexHTML(fs.readFileSync(__dirname + '/../public/index.html', {encoding: 'utf8'}));
|
|
||||||
setImmediate(callback);
|
var self = this;
|
||||||
|
|
||||||
|
var indexFile = __dirname + '/../public/index.html';
|
||||||
|
|
||||||
|
fs.readFile(indexFile, { encoding: 'utf8' }, function(err, data) {
|
||||||
|
|
||||||
|
if(err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.indexFile = self.filterIndexHTML(data);
|
||||||
|
callback();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
InsightUI.prototype.getRoutePrefix = function() {
|
InsightUI.prototype.getRoutePrefix = function() {
|
||||||
@ -35,14 +47,13 @@ InsightUI.prototype.setupRoutes = function(app, express) {
|
|||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
app.use('/', function(req, res, next){
|
app.use('/', function(req, res, next){
|
||||||
if (req.headers.accept && req.headers.accept.indexOf('text/html') !== -1 &&
|
|
||||||
req.headers["X-Requested-With"] !== 'XMLHttpRequest'
|
if (req.url === '/') {
|
||||||
) {
|
|
||||||
res.setHeader('Content-Type', 'text/html');
|
|
||||||
res.send(self.indexFile);
|
res.send(self.indexFile);
|
||||||
} else {
|
} else {
|
||||||
express.static(__dirname + '/../public')(req, res, next);
|
express.static(__dirname + '/../public')(req, res, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user