Static file server for react applications that are created using creat-react-app
const express = require('express');
const path = require('path');
const app = express();
app.use(express.static('./build'));
app.get('/*', function (req, res) {
res.sendFile(path.join(__dirname, './build', 'index.html'));
});
// Start the server
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
console.log('Press Ctrl+C to quit.');
});