Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,151 members, 7,818,467 topics. Date: Sunday, 05 May 2024 at 04:26 PM

Help With Node.js App Deployment To Heroku (Solved!!!) - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Help With Node.js App Deployment To Heroku (Solved!!!) (701 Views)

What Other Alternative To Heroku / Why Is Heroku Not Setting My Cookie / Help On Deployment On Heroku (2) (3) (4)

(1) (Reply) (Go Down)

Help With Node.js App Deployment To Heroku (Solved!!!) by ekrizz(m): 8:36am On Sep 02, 2020
Good day, fellow developers. I am taking a tutorial on Node.js and developed an app with Express, MongoDB atlas, etc. I used Passport-Google OAuth 2.0 for the login. Everything works well on my local machine, but it is giving me error when I deployed to Heroku. The error log is shown in the attached photo. When I run "heroku local web" on my terminal, it works fine, too. I've looked almost everywhere for solution, and tried many things; but none worked. Please, I need any help I can get to resolve this. Thank you.

Please, I apologize for the poor quality image

Re: Help With Node.js App Deployment To Heroku (Solved!!!) by afuye(m): 9:39am On Sep 02, 2020
Lemme see the script you ran.
I hope u didn't use nodemon in production.

ekrizz:
Good day, fellow developers. I am taking a tutorial on Node.js and developed an app with Express, MongoDB atlas, etc. I used Passport-Google OAuth 2.0 for the login. Everything works well on my local machine, but it is giving me error when I deployed to Heroku. The error log is shown in the attached photo. When I run "heroku local web" on my terminal, it works fine, too. I've looked almost everywhere for solution, and tried many things; but none worked. Please, I need any help I can get to resolve this. Thank you.

Please, I apologize for the poor quality image
Re: Help With Node.js App Deployment To Heroku (Solved!!!) by ekrizz(m): 10:28am On Sep 02, 2020
afuye:
Lemme see the script you ran.
I hope u didn't use nodemon in production.


No, I only used it in development.

This is the link to my repo

github(dot)com/OkekeChristian24/share-your-thought-app

Thanks for your help
Re: Help With Node.js App Deployment To Heroku (Solved!!!) by ekrizz(m): 12:57pm On Sep 02, 2020
Please, guys don't just view the post and pass. I really need to make this app work.
Re: Help With Node.js App Deployment To Heroku (Solved!!!) by cixak95211: 2:21pm On Sep 02, 2020
Debugging itself is an art that has to be learned. The crashalytics gave you a file where the error is contained.
I can help you but first you must help yourself.

step 1. Login to heroku bash and
step 2. "cat" that file and read the log, to understand why the error happened

Then come back and report what you discovered.
Re: Help With Node.js App Deployment To Heroku (Solved!!!) by cixak95211: 2:34pm On Sep 02, 2020


Not errors that made your app crash, but just point to other errors in your app.

App js line 24
should be "extended"

methodOverride not needed except in special cases,
were you just copying and pasting from the tutorial?

line 40
morgan is using dev. heroku will run natually in production, and morgan would not log anything meaningful,
better to use a custom logger or at least, morgan combined format

i can see you r doing schema validation in your models, it is way better to handle input validation at the very first layer,
so that errors are caught very early . . instead of troubling javacript all the way down the layers, only to fail a validation just before insertion into DB...
for a quick fix, a package like Joi comes to mind

middlware auth.js line 5 and co.

you dont need to an else statement, if the "if block" contains a return statement. after your if block, just write the other condition, since it will always return if the "if block is activated"

you followed the MVC pattern partially, no controllers. . .
plus you need to start learnign EcmaScript 6+, as it will make your life easier
and code easy to follow thru

and next time, pls add a sample .env file, so people can clone and run your project correctly. that was the only thing holding me back,
as i am too busy to scan the whole codebase for "process.env" annotations.
Re: Help With Node.js App Deployment To Heroku (Solved!!!) by ekrizz(m): 5:35pm On Sep 02, 2020
cixak95211:
Debugging itself is an art that has to be learned. The crashalytics gave you a file where the error is contained.
I can help you but first you must help yourself.

step 1. Login to heroku bash and
step 2. "cat" that file and read the log, to understand why the error happened

Then come back and report what you discovered.


God bless you for your help, boss.
As you instructed, I did the "cat" of the strategy.js file as pointed out by the logger. First and second pictures shows the code (in Heroku CLI and Brackets editor, respectively) that triggered the error. I don't know why it is so because the Client ID was set as shown by the third to the last pictures. 3rd picture is the config.env file, the 4th picture shows as used in Passport-Google strategy, and the fifth picture shows it as Heroku config var. I still need your input. Thanks
Re: Help With Node.js App Deployment To Heroku (Solved!!!) by ekrizz(m): 5:35pm On Sep 02, 2020
cixak95211:
Debugging itself is an art that has to be learned. The crashalytics gave you a file where the error is contained.
I can help you but first you must help yourself.

step 1. Login to heroku bash and
step 2. "cat" that file and read the log, to understand why the error happened

Then come back and report what you discovered.

This is the fifth picture

Re: Help With Node.js App Deployment To Heroku (Solved!!!) by ekrizz(m): 5:38pm On Sep 02, 2020
cixak95211:

.

I've made corrections for the errors you pointed out. I still don't know much about Morgan. I guess I'll leave it for now. Let me redeploy and see. Thank you once again
Re: Help With Node.js App Deployment To Heroku (Solved!!!) by ekrizz(m): 7:17pm On Sep 02, 2020
Finally, I've resolved it.
I added the Google client ID and secret to Heroku config vars, and it worked.
Thank you.
Re: Help With Node.js App Deployment To Heroku (Solved!!!) by ekrizz(m): 7:19pm On Sep 02, 2020
cixak95211:
Debugging itself is an art that has to be learned. The crashalytics gave you a file where the error is contained.
I can help you but first you must help yourself.

step 1. Login to heroku bash and
step 2. "cat" that file and read the log, to understand why the error happened

Then come back and report what you discovered.

Thank you, boss, for your help. You're the real MVP. I'll like you to mentor me Node.js. I'm actually good with PHP, but still picking up on Node.js
Re: Help With Node.js App Deployment To Heroku (Solved!!!) by cixak95211: 8:39pm On Sep 02, 2020
ekrizz:


Thank you, boss, for your help. You're the real MVP. I'll like you to mentor me Node.js. I'm actually good with PHP, but still picking up on Node.js

See you solved it, great! I was kinda bogged down with work and couldn't come online.
I rechecked the codebase and see you cleaned up a bit. At least, that makes for improvement. One step at a time.

If you have free internet, i'll like you to very much watch other contents on debugging, cos when you get to working in a production environment,
you'll spend most of your time debugging "other people's errors" and those you created yourself.

As per the mentoring, we'll see how it goes. I am always bogged down with work, but if you do run into issues, just let me know. Trust me, i'll not solve them for you, i'll just tell you what to do and you'll have to solve it yourself [to learn].

Cheers.
Re: Help With Node.js App Deployment To Heroku (Solved!!!) by ekrizz(m): 7:15am On Sep 03, 2020
cixak95211:


See you solved it, great! I was kinda bogged down with work and couldn't come online.
I rechecked the codebase and see you cleaned up a bit. At least, that makes for improvement. One step at a time.

If you have free internet, i'll like you to very much watch other contents on debugging, cos when you get to working in a production environment,
you'll spend most of your time debugging "other people's errors" and those you created yourself.

As per the mentoring, we'll see how it goes. I am always bogged down with work, but if you do run into issues, just let me know. Trust me, i'll not solve them for you, i'll just tell you what to do and you'll have to solve it yourself [to learn].

Cheers.

I appreciate, boss. I'd really like you to point out some resources on debugging codes (especially YouTube videos or ebooks) if possible.

I have always known that it's better to teach one how to fish rather than giving him fish, so I would love it if you give directions on what to do just like you did above. Let me send you a PM. I don't know if your mail works, mine do.
Thank you.
Re: Help With Node.js App Deployment To Heroku (Solved!!!) by cixak95211: 7:50am On Sep 03, 2020
ekrizz:


I appreciate, boss. I'd really like you to point out some resources on debugging codes (especially YouTube videos or ebooks) if possible.

I have always known that it's better to teach one how to fish rather than giving him fish, so I would love it if you give directions on what to do just like you did above. Let me send you a PM. I don't know if your mail works, mine do.
Thank you.

Nah, that's a burner email. I guess if you use the follow button, we'll be able to exchange comms pretty effectively.
Re: Help With Node.js App Deployment To Heroku (Solved!!!) by ekrizz(m): 9:45am On Sep 03, 2020
cixak95211:


Nah, that's a burner email. I guess if you use the follow button, we'll be able to exchange comms pretty effectively.

Okay, boss. I just clicked the follow button.
Re: Help With Node.js App Deployment To Heroku (Solved!!!) by HassieMalcomson(f): 10:31am On Dec 18, 2022
It sounds great that you have solved it but I think newbies can also contact to Heroku support in case of such issues. If I share my experience, I have been using Heroku for years and it was an outstanding experience. I was a big fan of the free-tier programs of Heroku but recently, this app deployment platform just changed its policy and there is no freemium plan anymore.

Therefore, I left Heroku this year and chose Back4App for my Node.js app deployment tasks. This platform still has freemium plans and services and I don't need to insert my credit card details in this regard. Hereof, this guide https://blog.back4app.com/how-to-deploy-node-js-application/ confers you with all details about deploying a Node.js application by using the Back4App platform. This guide allows you to proceed with web hosting and database with ParseJS.

Luckily, the free plan of this cloud vendor permits you following features:

- 25k requests
- 250 MB data storage
- 1 GB transfer
- 1 GB file storage

(1) (Reply)

Need A Code Buddy/buddies In Enugu / Android App Developer Needed For Flight Booking And Hotel Booking App / I Need A Programmer Skilled And Versatile In Full Stack Web Development

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 40
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.