Skip to content

Commit e9eaf0d

Browse files
authored
Merge pull request #118 from Treevyy/servermove
server errors
2 parents 3e349c5 + 22f23a5 commit e9eaf0d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

server/src/server.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff 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}`);

0 commit comments

Comments
 (0)