Last active
June 30, 2017 16:04
-
-
Save lopezjurip/4e54213f0231b73ff551fced61bd9a02 to your computer and use it in GitHub Desktop.
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
// server/app.js | |
const express = require('express'); | |
const morgan = require('morgan'); | |
const path = require('path'); | |
const app = express(); | |
// Setup logger | |
app.use(morgan(':remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length] :response-time ms')); | |
// Serve static assets | |
app.use(express.static(path.resolve(__dirname, '..', 'build'))); | |
// Always return the main index.html, so react-router render the route in the client | |
app.get('*', (req, res) => { | |
res.sendFile(path.resolve(__dirname, '..', 'build', 'index.html')); | |
}); | |
module.exports = app; |
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
// server/index.js | |
'use strict'; | |
const app = require('./app'); | |
const PORT = process.env.PORT || 9000; | |
app.listen(PORT, () => { | |
console.log(`App listening on port ${PORT}!`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment