To fix Heroku Node.js app deploy failed error code=H10
, we should not hard code the port for our app.
For instance, we write
app.listen(process.env.PORT || 3000, () => {});
to call listen
with the PORT
environment variable or 3000 as a fallback to run with the port from the environment variable or on port 3000 as the default.