File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed
Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,17 @@ const startApolloServer = async () => {
5353 app . use ( express . urlencoded ( { extended : false } ) ) ;
5454 app . use ( express . json ( ) ) ;
5555
56+ const clientDistPath = path . join ( __dirname , '../../client/dist' ) ;
57+ if ( fs . existsSync ( clientDistPath ) ) {
58+ app . use ( express . static ( clientDistPath ) ) ;
59+ app . get ( '*' , ( _req : Request , res : Response ) => {
60+ res . sendFile ( path . join ( clientDistPath , 'index.html' ) ) ;
61+ } ) ;
62+
63+ } else {
64+ console . warn ( '⚠️ Static files not found. Ensure the client has been built.' ) ;
65+ }
66+
5667 // ✅ API routes
5768 app . use ( '/api' , openaiRoutes ) ;
5869
@@ -64,15 +75,6 @@ const startApolloServer = async () => {
6475 res . send ( '🎙️ Codezilla server is up!' ) ;
6576 } ) ;
6677
67- const clientDistPath = path . join ( __dirname , '../../client/dist' ) ;
68- if ( fs . existsSync ( clientDistPath ) ) {
69- app . use ( express . static ( clientDistPath ) ) ;
70- app . get ( '*' , ( _req : Request , res : Response ) => {
71- res . sendFile ( path . join ( clientDistPath , 'index.html' ) ) ;
72- } ) ;
73- } else {
74- console . warn ( '⚠️ Static files not found. Ensure the client has been built.' ) ;
75- }
7678
7779 app . listen ( PORT , ( ) => {
7880 console . log ( `✅ Server is running on http://localhost:${ PORT } ` ) ;
You can’t perform that action at this time.
0 commit comments