ga-wdi-exercises/project4

Deployment issue

Closed this issue · 8 comments

I failed at deploying my app on heroku (it is pure front end, AngularJS and Websockets) and even though I could probably do a tutorial or something to refresh my memory, I would love a final consult. Am happy to spend my group's final token from project 3.

Thaaaannnnkkkssss

By "failed at deploying" do you mean that the heroku deployment aborted with an error, or that after completing deployment there is some breaking error that prevents it from running on heroku?

Also could you supply some links to your repo(s) and the deployed app?

Sure thing, one moment. I'll redeploy

Repo: https://github.com/mattcfilbert/websocketChat
Deployed: https://connect-2-by-4.herokuapp.com/

After deploying, there is a generic application error. I'm sure there was a human error on my end somewhere.

EDIT: updated URL

We might need to inspect the server logs to see what might be wrong, but I suspect the issue is that you're hard-coding port 3001 in your server. Heroku insists that your app use the port number they provide via process.env.PORT

Try adding this line near the top of your script...

const port = process.env.PORT || 3001

...then when you fire up the server, use that variable instead of 3001:

http.listen(port, () => {
  console.log(`listening on ${port}`)
})

Hmm, that sounded like the issue, but unfortunately making that change did not resolve the error.

Do I need to make npm start an alias for node index.js or something?

Ah, yes. You need a "start" entry in your package.json "scripts" section. This is how heroku kickstarts your app. Just add one with node index.js and that will get you up and running:

  "scripts": {
    "start": "node index.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },

That works! Thanks, Juan!