@@ -8,9 +8,10 @@ dotenv.config();
88
99const app = express ( ) ;
1010const PORT = process . env . PORT || 3007 ;
11+ const HOST = process . env . HOST || '0.0.0.0' ;
1112
1213// Configure base path from environment or use '/frontend' as default
13- const BASE_PATH = process . env . BASE_PATH || '' ;
14+ const BASE_PATH = process . env . BASE_PATH || '/frontend ' ;
1415
1516app . set ( 'view engine' , 'ejs' ) ;
1617app . set ( 'views' , path . join ( __dirname , 'views' ) ) ;
@@ -24,25 +25,25 @@ app.use(session({
2425 saveUninitialized : true ,
2526} ) ) ;
2627
27- // Health check at root path for Kubernetes probes
28- app . get ( ' /health' , ( req , res ) => {
28+ // Unified health check
29+ app . get ( ` ${ BASE_PATH } /health` , ( req , res ) => {
2930 res . json ( {
3031 status : 'UP' ,
3132 details : 'Frontend service healthy'
3233 } ) ;
3334} ) ;
3435
35- // Root redirect - now using BASE_PATH
36+ // Root redirect
3637app . get ( '/' , ( req , res ) => {
3738 res . redirect ( `${ BASE_PATH } /login` ) ;
3839} ) ;
3940
40- // Show login page
41+ // Login page
4142app . get ( `${ BASE_PATH } /login` , ( req , res ) => {
4243 res . render ( 'login' , { error : null } ) ;
4344} ) ;
4445
45- // Submit login form
46+ // Login submit
4647app . post ( `${ BASE_PATH } /login` , async ( req , res ) => {
4748 const { username, password } = req . body ;
4849
@@ -60,7 +61,7 @@ app.post(`${BASE_PATH}/login`, async (req, res) => {
6061 }
6162} ) ;
6263
63- // Protected dashboard
64+ // Dashboard
6465app . get ( `${ BASE_PATH } /dashboard` , async ( req , res ) => {
6566 if ( ! req . session . token ) return res . redirect ( `${ BASE_PATH } /login` ) ;
6667
@@ -80,15 +81,6 @@ app.get(`${BASE_PATH}/dashboard`, async (req, res) => {
8081 }
8182} ) ;
8283
83- // Additional health check at prefixed path for backward compatibility
84- app . get ( `${ BASE_PATH } /health` , ( req , res ) => {
85- res . json ( {
86- status : 'UP' ,
87- details : 'Frontend service healthy'
88- } ) ;
84+ app . listen ( PORT , HOST , ( ) => {
85+ console . log ( `Frontend running on http://${ HOST } :${ PORT } ${ BASE_PATH } ` ) ;
8986} ) ;
90-
91- app . listen ( PORT , ( ) => {
92- console . log ( `Frontend running on port ${ PORT } ` ) ;
93- console . log ( `Using base path: '${ BASE_PATH } '` ) ;
94- } ) ;
0 commit comments