Skip to content

Instantly share code, notes, and snippets.

@cristiangrojas
Created August 3, 2018 16:22
Show Gist options
  • Save cristiangrojas/0bb91f191b1f5522227b2865b225c396 to your computer and use it in GitHub Desktop.
Save cristiangrojas/0bb91f191b1f5522227b2865b225c396 to your computer and use it in GitHub Desktop.
Simple server in Express.js for create-react-app build copy
const express = require('express');
const bodyParser = require('body-parser')
const path = require('path');
const app = express();
app.use(express.static(path.join(__dirname, 'build')));
app.get('/*', function (req, res) {
res.sendFile(path.join(__dirname, 'build-copy', 'index.html'));
});
app.listen(process.env.PORT || 8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment