@@ -520,34 +520,36 @@ app.get(
520
520
) ;
521
521
522
522
// serve index.html on the route '/'
523
- const isDocker = process . env . IS_DOCKER === 'true' ;
524
- console . log ( 'this is running on docker: ' , isDocker ) ;
523
+ // const isDocker = process.env.IS_DOCKER === 'true';
524
+ // console.log('this is running on docker: ', isDocker);
525
525
526
526
//if in production mode, statically serve everything in the build folder on the route '/dist'
527
527
if ( process . env . NODE_ENV == 'production' ) {
528
+ console . log ( 'in production' ) ;
529
+ console . log ( 'dirname: ' , __dirname ) ;
528
530
app . use ( '/' , express . static ( path . join ( __dirname , '/build' ) ) ) ;
531
+ } else {
532
+ console . log ( 'not production' ) ;
533
+ console . log ( 'dirname: ' , __dirname ) ;
534
+ app . get ( '/' , ( req , res ) => {
535
+ const indexPath = path . join ( __dirname , '../index.html' ) ;
536
+ return res . status ( 200 ) . sendFile ( indexPath ) ;
537
+ } ) ;
529
538
}
530
539
531
- app . get ( '/' , ( req , res ) => {
532
- const indexPath = isDocker
533
- ? path . join ( __dirname , '../index-prod.html' )
534
- : path . join ( __dirname , '../index.html' ) ;
535
- return res . status ( 200 ) . sendFile ( indexPath ) ;
536
- } ) ;
537
-
538
540
// app.get('/bundle.js', (req, res) => {
539
541
// return res.status(200).sendFile(path.join(process.cwd(), 'bundle.js'));
540
542
// });
541
543
542
- if ( isDocker ) {
543
- app . get ( '/main.css' , ( req , res ) => {
544
- return res . status ( 200 ) . sendFile ( path . join ( process . cwd ( ) , 'main.css' ) ) ;
545
- } ) ;
546
- }
544
+ // if (isDocker) {
545
+ // app.get('/main.css', (req, res) => {
546
+ // return res.status(200).sendFile(path.join(process.cwd(), 'main.css'));
547
+ // });
548
+ // }
547
549
548
- app . get ( '/test' , ( req , res ) => {
549
- res . send ( 'test request is working' ) ;
550
- } ) ;
550
+ // app.get('/test', (req, res) => {
551
+ // res.send('test request is working');
552
+ // });
551
553
552
554
app . use ( '/*' , ( req , res ) => res . status ( 404 ) . send ( 'Page not found' ) ) ;
553
555
0 commit comments