Created
March 6, 2017 15:28
-
-
Save niksudan/e7c5d942db5b413ee4d19cb5f5740bc9 to your computer and use it in GitHub Desktop.
Host a create-react-app build folder with express
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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