Skip to content

Instantly share code, notes, and snippets.

@Hoang-Minh
Last active August 13, 2020 18:10
Show Gist options
  • Save Hoang-Minh/cc5431a13c19aa1b63fecd239149f2fe to your computer and use it in GitHub Desktop.
Save Hoang-Minh/cc5431a13c19aa1b63fecd239149f2fe to your computer and use it in GitHub Desktop.
1. In the server folder, package.json folder, add these node values:
"engines": {
"node": "12.13.0",
"npm": "6.12.0"
},
and
2. "heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm i --prefix client && npm run build --prefix client"
3. if (process.env.NODE_ENV === "production") {
// Express will serve up production assets
// like our main.js file or main.css file
app.use(express.static("client/build"));
// Express will serve up the index.html file if it doesn't recognize the route
const path = require("path");
app.get("*", (req, res) => {
res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
});
}
4. In the server, check package.json, see if we have start script:
"start": "node index.js",
5. Don't forget any REACT_APP_ environment variable if there is !!!!
*****************************************************
heroku login -i
heroku create
heroku apps
If app already mapped, remap it:
heroku git:remote <new_app>
If not, push to heroku master
git push heroku master
Link: https://devcenter.heroku.com/articles/heroku-cli-commands
https://devcenter.heroku.com/articles/maintenance-mode
https://dev.to/lawrence_eagles/causes-of-heroku-h10-app-crashed-error-and-how-to-solve-them-3jnl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment