Last active
April 26, 2018 10:41
-
-
Save eiriklv/f718084114f7b9852c056e970c3f1f6d to your computer and use it in GitHub Desktop.
Simple server
This file contains 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
/** | |
* Dependencies | |
*/ | |
const express = require('express'); | |
const history = require('connect-history-api-fallback'); | |
/** | |
* Environment / configuration | |
*/ | |
const port = process.env.PORT || 3000; | |
/** | |
* Create our express app | |
*/ | |
const app = express(); | |
/** | |
* Use history fallback | |
*/ | |
app.use(history()); | |
/** | |
* Serve static files from the appropriate folder | |
*/ | |
app.use(express.static(`${__dirname}/../../build`)); | |
/** | |
* Attach server to port | |
*/ | |
app.listen(port, () => { | |
console.log(`frontend-app listening to port ${port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment