Spaces:
Runtime error
Runtime error
Commit ·
b4331db
1
Parent(s): 83ee865
Configure server to serve frontend static files
Browse files- backend/server.js +8 -0
backend/server.js
CHANGED
|
@@ -21,6 +21,14 @@ app.get('/api/health', (req, res) => {
|
|
| 21 |
res.json({ status: 'OK', message: 'PubMed AI Explorer API is running' });
|
| 22 |
});
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
app.listen(PORT, () => {
|
| 25 |
console.log(`Server running on port ${PORT}`);
|
| 26 |
});
|
|
|
|
| 21 |
res.json({ status: 'OK', message: 'PubMed AI Explorer API is running' });
|
| 22 |
});
|
| 23 |
|
| 24 |
+
// Serve static files from the React app build directory
|
| 25 |
+
app.use(express.static(path.join(__dirname, '../frontend/dist')));
|
| 26 |
+
|
| 27 |
+
// Catch all handler: send back React's index.html file for any non-API routes
|
| 28 |
+
app.get('*', (req, res) => {
|
| 29 |
+
res.sendFile(path.join(__dirname, '../frontend/dist/index.html'));
|
| 30 |
+
});
|
| 31 |
+
|
| 32 |
app.listen(PORT, () => {
|
| 33 |
console.log(`Server running on port ${PORT}`);
|
| 34 |
});
|