Fix: Ensure static files are served and NODE_ENV is forced to production on HF
Browse files- packages/server/src/index.ts +12 -13
- scripts/start-hf.sh +1 -0
packages/server/src/index.ts
CHANGED
|
@@ -39,20 +39,19 @@ app.use('/api/v1', apiRoutes);
|
|
| 39 |
// Error handler
|
| 40 |
app.use(errorHandler);
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
res.sendFile(path.join(clientPath, 'index.html'));
|
| 54 |
});
|
| 55 |
-
}
|
| 56 |
|
| 57 |
// WebSocket
|
| 58 |
setupWebSocketHandlers(io);
|
|
|
|
| 39 |
// Error handler
|
| 40 |
app.use(errorHandler);
|
| 41 |
|
| 42 |
+
const clientPath = path.join(__dirname, '../../client/dist');
|
| 43 |
+
|
| 44 |
+
// Serve static frontend
|
| 45 |
+
app.use(express.static(clientPath));
|
| 46 |
+
|
| 47 |
+
// Fallback for SPA routing and root
|
| 48 |
+
app.get('*', (req, res) => {
|
| 49 |
+
res.sendFile(path.join(clientPath, 'index.html'), (err) => {
|
| 50 |
+
if (err && !res.headersSent) {
|
| 51 |
+
res.status(404).send('GLMPilot: Frontend build not found. Please ensure npm run build was successful.');
|
| 52 |
+
}
|
|
|
|
| 53 |
});
|
| 54 |
+
});
|
| 55 |
|
| 56 |
// WebSocket
|
| 57 |
setupWebSocketHandlers(io);
|
scripts/start-hf.sh
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
#!/bin/bash
|
|
|
|
| 2 |
# Start Redis in the background with essential flags for containerized environments
|
| 3 |
echo "Starting Redis server..."
|
| 4 |
redis-server --daemonize yes --protected-mode no
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
+
export NODE_ENV=production
|
| 3 |
# Start Redis in the background with essential flags for containerized environments
|
| 4 |
echo "Starting Redis server..."
|
| 5 |
redis-server --daemonize yes --protected-mode no
|