Skip to content

Instantly share code, notes, and snippets.

@teodragovic
Last active February 6, 2017 13:05
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 teodragovic/737daf99362b99d3892e64d21ddf084d to your computer and use it in GitHub Desktop.
Save teodragovic/737daf99362b99d3892e64d21ddf084d to your computer and use it in GitHub Desktop.
min. heroku config for react app
{
"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"
}
}
// 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