简体   繁体   中英

Calling node.js webserver from scheduler process using heroku

I am using Heroku hosting and have setup a node.js webserver. I now want to run another node script that will send periodic POST requests to the node.js webserver utilizing the Heroku scheduler. When I'm running on my own machine I run the script that generates the POST request as follows:

var request = require('request');
...
request.post("http://localhost:5000/submit").form(some_json_data);

However when I want to deploy to Heroku I want to ensure I want to use the correct HOST and PORT settings (I'm sure the port the webserver runs on won't be 5000 for example). How can achieve this?

Your scheduler job will spin up a new dyno, so if you want to make a post, you'll have to do it to yourapp.heorkuapp.com or yourcustomdomain.com . You therefore do need to care about the port.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM