Skip to content

Instantly share code, notes, and snippets.

@niksudan
Created March 6, 2017 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niksudan/e7c5d942db5b413ee4d19cb5f5740bc9 to your computer and use it in GitHub Desktop.
Save niksudan/e7c5d942db5b413ee4d19cb5f5740bc9 to your computer and use it in GitHub Desktop.
Host a create-react-app build folder with express
const express = require('express');
const app = express();
// 80 won't work if another process uses this port (apache/nginx)
const SERVER_PORT = 80;
app.get('*', express.static(__dirname + '/build'));
app.get('*', (req, res) => {
res.sendFile(__dirname + '/build/index.html');
})
app.listen(SERVER_PORT);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment