Reputation: 6800
Sorry for confusing title, new to Node.js and Heroku, but trying to quickly pick it up.
I currently own a domain, and my first goal is to have it set up so I go to the domain, it uses Heroku to wake up and run Node.js, run my web.js, and display "Hello world".
I've already gone through this heroku/node.js tutorial, and so I understand how to set up stuff locally, push to the heroku remote, and run my Node.js server with it (am I understanding that correctly?). However, I couldn't find anything for how you actually put your Node.js files onto your external server (so, in this case, my domain), and connect the service of Heroku to those files, allowing my local machine to interact with the node on my server.
If there's any tutorials or pages you'd recommend, I'd appreciate it. Kinda stuff and most likely confused on quite a few things here. Thanks!
Upvotes: 1
Views: 705
Reputation: 29436
Heroku apps have their own git repository. So, you push
from your local git directory to heroku's git remote.
Setup:
git remote add heroku <git://yourherokurepourl.git>
and then every time to deploy:
git push heroku
That's all needed to get your node.js files on heroku's server. Heroku follows foreman
as process launcher. foreman
needs a special file in project root called procfile
. procfile
has simple unix commands to launch processes in each line :
web : npm install && node app.js
So, when you push your project to heroku's git. It will look for procfile
and launch processes defined there. You can place more commands here. Better install foreman
on your local/development machine and test using that.
In heroku app settings you can "bind" your www.domain.com
address to node app running on heroku's server. You have to do the same in settings of domain provider. The DNS will now route requests to www.domain.com
to your app's server IP.
On heroku, configuration lives in environment. A lot many process.env.*
are available on heroku. You can locally simulate this by providing .env
files to foreman
.
finally, in your node.js code make sure you listen on value provided by process.env.PORT
.
Connecting servers:
Request
module to directly call other server urls.Upvotes: 2
Reputation: 1114
You are describing operating two servers. One on Heroku, one "on your domain". I suspect you haven't made the connection that you can merely get your domain to point to your Heroku server. Contact your domain name provider with the heroku url you are using and they can do this for you.
In effect they will "point" your domain to your Heroku node.js server and from there it will act as you expect.
Upvotes: 0