@@ -11,10 +11,19 @@ const app = globalAPI;
11
11
const log = console . log ;
12
12
var envConfigFilename = "env_config.json" ;
13
13
var envConfigFilePath = path . join ( __dirname , envConfigFilename ) ;
14
+ var isReactBundlePresent = false ;
14
15
15
- // DATABASE_FILE = path.join(__dirname, ".", DATABASE_FILE);
16
+ try {
17
+ fs . accessSync ( path . join ( __dirname , "." , "build" ) ) ;
18
+ isReactBundlePresent = true ;
19
+ } catch ( err ) {
20
+ log ( "ERROR: " , err ) ;
21
+ isReactBundlePresent = false ;
22
+ }
16
23
17
- app . use ( express . static ( path . join ( __dirname , "build" ) ) ) ;
24
+ if ( isReactBundlePresent ) {
25
+ app . use ( express . static ( path . join ( __dirname , "build" ) ) ) ;
26
+ }
18
27
19
28
function getEnvData ( ) {
20
29
try {
@@ -107,7 +116,9 @@ log("INFO: Config file is present");
107
116
log ( "INFO: Reading from config file " + envConfigFilePath ) ;
108
117
109
118
app . get ( "/*" , ( req , res ) => {
110
- res . sendFile ( path . join ( __dirname , "build" , "index.html" ) ) ;
119
+ if ( isReactBundlePresent ) {
120
+ res . sendFile ( path . join ( __dirname , "build" , "index.html" ) ) ;
121
+ }
111
122
} ) ;
112
123
113
124
globalAPI . listen ( getEnvData ( ) . GITCONVEX_PORT || 9001 , async ( err ) => {
0 commit comments