[solved] Need Heroku Help ... have read other threads. Git to Heroku not working

I have read through this thread and don’t understand (have not researched) the things discussed like the .env file and dotenv, etc.

My issue…I have the time stamp service working locally (YAY) and have followed the instructions to push to heroku.

My heroku app is not working.

I am guessing this is a port problem ,and would like to learn the best way to code the port while developing to eliminate this problem, if in fact that’s the problem.

I do not know what to do with a .env file, but can appreciate that I may need to learn.

The deployment if this simple node app is certainly a challenge…but important to solve!

thanks for any help…here is my repository:

On the Heroku end, I’ve used both the CLI and deployed from git from the master branch. I don’t know if one is preferred…seems better to push once and have it deploy automatically, assuming the master branch is always working.

Thanks for any help.

You’re right: the port is the problem.

You have hardcoded your server to listen on port 5000, but Heroku will determine for itself what port it wants to make available to your app.

This means you need to set the port as either whatever Heroku decides, or default to your own choice when developing locally.

Use this middleware to set the port: app.set('port', (process.env.PORT || 5000)) (somewhere above your routes, I think)

and then change the listen block to this:

app.listen(app.get('port'), function() {
  console.log('Node app is running on port', app.get('port'));

This becomes more relevant once you start needing to hide authentication details for your database or want to hide API keys.

THANK YOU!!! WOOHOO! I feel like a developer now! It works!

You can also navigate to myherokuURL/cool and see some cool ascii faces I added as part of the heroku tutorial.

Fantastic. This tidbit needs to be added to the “get ready for apis” in the FCC instructions.

1 Like

I get the part about the authentication details now. Thanks