File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed
Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -23,8 +23,20 @@ InsightUI.dependencies = ['insight-api'];
2323inherits ( InsightUI , BaseService ) ;
2424
2525InsightUI . prototype . start = function ( callback ) {
26- this . indexFile = this . filterIndexHTML ( fs . readFileSync ( __dirname + '/../public/index.html' , { encoding : 'utf8' } ) ) ;
27- setImmediate ( callback ) ;
26+
27+ var self = this ;
28+
29+ var indexFile = __dirname + '/../public/index.html' ;
30+
31+ fs . readFile ( indexFile , { encoding : 'utf8' } , function ( err , data ) {
32+
33+ if ( err ) {
34+ return callback ( err ) ;
35+ }
36+
37+ self . indexFile = self . filterIndexHTML ( data ) ;
38+ callback ( ) ;
39+ } ) ;
2840} ;
2941
3042InsightUI . prototype . getRoutePrefix = function ( ) {
@@ -35,14 +47,13 @@ InsightUI.prototype.setupRoutes = function(app, express) {
3547 var self = this ;
3648
3749 app . use ( '/' , function ( req , res , next ) {
38- if ( req . headers . accept && req . headers . accept . indexOf ( 'text/html' ) !== - 1 &&
39- req . headers [ "X-Requested-With" ] !== 'XMLHttpRequest'
40- ) {
41- res . setHeader ( 'Content-Type' , 'text/html' ) ;
50+
51+ if ( req . url === '/' ) {
4252 res . send ( self . indexFile ) ;
4353 } else {
4454 express . static ( __dirname + '/../public' ) ( req , res , next ) ;
4555 }
56+
4657 } ) ;
4758} ;
4859
You can’t perform that action at this time.
0 commit comments