ericmdantas / generator-ng-fullstack

Client, server or fullstack - it's up to you. ng-fullstack gives you the best of the latest.
MIT License
704 stars 103 forks source link

heroku api issue #97

Closed itranga closed 8 years ago

itranga commented 8 years ago

I hosted sample app in https://mytemple.herokuapp.com/ . I got following issue in console .

https://mytemple.herokuapp.com/api/todos/ 503 (Service Unavailable).

I connected mongodb in mongolab

ericmdantas commented 8 years ago

Hello, @itranga.

Did you change the MONGOHQ_URL to MONGOLAB? https://github.com/ericmdantas/generator-ng-fullstack/blob/master/app/templates/server_node/config/db.conf.js#L8

itranga commented 8 years ago

Yes . I have change it in db.json file .

"localhost": "mongodb://username:pwd@ds031952.mlab.com:31952/temple"

My local app is working fine .I have issue only in heroku server.I think it have some issue in api url .

ericmdantas commented 8 years ago

What's the content of your procfile.txt?

Change it to:

web: npm start
itranga commented 8 years ago

I have allready done . procfile = web: npm start

ericmdantas commented 8 years ago

Same error?

If so, is the deploy to heroku ok or there are some errors? Also, can you connect to the DB outside of the application?

itranga commented 8 years ago

I got the same error . I connected MONGO Db from https://mlab.com/ . I think issue is in router . Because I try to view https://mytemple.herokuapp.com/api/todos/. it's not working .But my local pc app router is working [ http://localhost:3333/api/todos ]

ericmdantas commented 8 years ago

Can you show some logs/prints?

itranga commented 8 years ago

Online

https://mytemple.herokuapp.com/api/todos/

Chrome Print

Application Error An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details.

Offline

http://localhost:3333/api/todos/

Chrome Print

[{"_id":"56f49f682f31c84360a6c018","todoMessage":"test","v":0,"createdAt":"2016-03-25T02:16:08.587Z"},{"_id":"56f4a399a1bfc50d6435f672","todoMessage":"test2","__v":0,"createdAt":"2016-03-25T02:34:01.606Z"},{"_id":"56f4e8a2d14e76e01d4220bc","todoMessage":"ssdsd","v":0,"createdAt":"2016-03-25T07:28:34.074Z"},{"_id":"56f77003d256cfdb04d6be26","todoMessage":"ranga","__v":0,"createdAt":"2016-03-27T05:30:43.903Z"}]

ericmdantas commented 8 years ago

I see, the page is showing, but there's no interaction with the server.

The thing I'm noticing is the request is taking forever to resolve. For example, the GET on api/todos took 1min and then got the 503 Service Unavailable error.

Are you using express to serve the index.html or some static server? If you're not using express, make sure your proxy is set up correctly.

itranga commented 8 years ago

I used your generator-ng-fullstack code .change only db.json file .

ericmdantas commented 8 years ago

You'll also have to change the enviroment variable for the Mongo connection.

By default, the generator uses MONGOHQ_URL to connect to the database. You'll have to use MONGOLAB_URI. That config is in server/config/db.config.js.

itranga commented 8 years ago

I have change MONGOHQ_URL to MONGOLAB_URI . Did u try to host your code heroku servers ?

ericmdantas commented 8 years ago

Yes - it's been a while, though.

Let me give it a try with a newer version.

ericmdantas commented 8 years ago

Alright, got it to work with mongolab: https://issue-97.herokuapp.com/

What I had to do:

The rest is just the default Heroku deploy steps.

https://devcenter.heroku.com/articles/git

itranga commented 8 years ago

Thank you so much for all you have done for me . I will follow your process

ericmdantas commented 8 years ago

Thanks for sticking by, and providing some feedback on how to reproduce it :smile:

ericmdantas commented 8 years ago

By the way, I created an explanation in the wiki to help other people that might run into similar problems: https://github.com/ericmdantas/generator-ng-fullstack/wiki/Deploying-to-Heroku

itranga commented 8 years ago

it's working now . I changed const URL = dbConst.localhost; in db.conf.ts . (Because Need to add Credit card to create mLab MongoDB in heroku )

I want again to thanks you for help and support

http://mytemple.herokuapp.com/

ericmdantas commented 8 years ago

Awesome! :+1: