Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mattiaerre
Last active April 3, 2017 08:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattiaerre/32cb87c726c7ecaa79f2a88b04508979 to your computer and use it in GitHub Desktop.
Save mattiaerre/32cb87c726c7ecaa79f2a88b04508979 to your computer and use it in GitHub Desktop.
How to run a CRA in Heroku w/ Express and Node.js build pack
/* info: the original "start" from CRA has been renamed to dev and a new "start" that points to server.js has been added */
{
"scripts": {
"start": "node server.js",
"dev": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
/*
* author: Mattia Richetto
* twitter: @mattiaerre
* email: mattia.richetto@gmail.com
* date: 12/10/2016
*/
const express = require('express');
const app = express();
app.use(express.static('build'));
const port = process.env.PORT || 3000;
app.listen(port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment