@@ -12,6 +12,7 @@ import { NgxRequest, NgxResponse } from '@gorniv/ngx-universal';
1212import * as compression from 'compression' ;
1313import * as cookieparser from 'cookie-parser' ;
1414import { exit } from 'process' ;
15+
1516// for debug
1617require ( 'source-map-support' ) . install ( ) ;
1718
@@ -26,8 +27,6 @@ const path = require('path');
2627const template = fs . readFileSync ( path . join ( '.' , 'dist' , 'index.html' ) ) . toString ( ) ;
2728// for mock global window by domino
2829const win = domino . createWindow ( template ) ;
29- // from server build
30- const files = fs . readdirSync ( `${ process . cwd ( ) } /dist-server` ) ;
3130// mock
3231global [ 'window' ] = win ;
3332// not implemented property and functions
@@ -94,11 +93,11 @@ export function app() {
9493 if ( test && req . url === '/test/exit' ) {
9594 res . send ( 'exit' ) ;
9695 exit ( 0 ) ;
97- return ;
9896 }
9997
10098 next ( ) ;
10199 } ) ;
100+
102101 // Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
103102 server . engine (
104103 'html' ,
@@ -111,7 +110,7 @@ export function app() {
111110 server . set ( 'views' , distFolder ) ;
112111
113112 // Example Express Rest API endpoints
114- // app .get('/api/**', (req, res) => { });
113+ // server .get('/api/**', (req, res) => { });
115114 // Serve static files from /browser
116115 server . get (
117116 '*.*' ,
@@ -122,7 +121,7 @@ export function app() {
122121
123122 // All regular routes use the Universal engine
124123 server . get ( '*' , ( req , res ) => {
125- global [ 'navigator' ] = req [ 'headers' ] [ 'user-agent' ] ;
124+ global [ 'navigator' ] = { userAgent : req [ 'headers' ] [ 'user-agent' ] } as Navigator ;
126125 const http =
127126 req . headers [ 'x-forwarded-proto' ] === undefined ? 'http' : req . headers [ 'x-forwarded-proto' ] ;
128127
0 commit comments