Last active
February 6, 2017 13:05
-
-
Save teodragovic/737daf99362b99d3892e64d21ddf084d to your computer and use it in GitHub Desktop.
min. heroku config for react 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
{ | |
"name": "heroku-server", | |
"version": "1.0.0", | |
"description": "Heroku server for React app", | |
"scripts": { | |
"start": "node server.js" | |
}, | |
"dependencies": { | |
"compression": "1.6.2", | |
"express": "4.14.1" | |
} | |
} |
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.js | |
var express = require('express'); | |
var path = require('path'); | |
var compression = require('compression'); | |
var app = express(); | |
app.use(compression()); | |
// serve our static stuff like index.css | |
app.use(express.static(path.join(__dirname, 'public'))); | |
// send all requests to index.html so browserHistory in React Router works | |
app.get('*', function(req, res) { | |
res.sendFile(path.join(__dirname, 'public', 'index.html')); | |
}); | |
var PORT = process.env.PORT || 8080; | |
app.listen(PORT, function() { | |
console.log('Production Express server running at localhost:' + PORT); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment