-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
24 lines (20 loc) · 755 Bytes
/
server.js
File metadata and controls
24 lines (20 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const express = require('express');
const path = require('path');
const app = express();
// Serve static files from the React app
app.use(express.static(path.join(__dirname, 'build')));
// Note: site_static_assets are now served from AWS S3, not locally
// Serve root assets folder (for favicon, robots.txt, etc.)
app.use(express.static(path.join(__dirname, 'assets')));
// Handle React routing, return all requests to React app
app.get('/*', function(req, res) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
const port = process.env.PORT || 5001;
app.listen(port, '0.0.0.0', (err) => {
if (err) {
console.error('Error starting server:', err);
process.exit(1);
}
console.log(`Server is running on port ${port}`);
});