I have a very simple direct node.js application [1] I want to deploy to a hero. Although I can expand it, the page may not be accessible in the browser.
I followed advice from the Getting Started with node.js in Heroku Guide [2]. When I launch the application using node index.jslocally, I can access the application in http://localhost:8080/index.jade, however, when I try to access it on heroku's http://immonow.herokuapp.com:8080/index.jade, it would throw me an HTTP error code ERR_CONNECTION_REFUSED.
How I deployed the application:
git commit -am "made changes"// commit changesgit push origin master// click on githeroku create// create a heroku applicationgit push heroku master// click on the heroheroku ps:scale web=1// launch workers
My node.js server:
#!/usr/bin/env node
var http = require('http')
, jade = require('jade')
, static = require('node-static')
, jadeRe = /\.jade$/
, path = process.argv.slice(2)[0]
, fileServer = new static.Server(path || '.')
http.createServer(function (req, res) {
if (req.url.match(jadeRe)) {
res.writeHead(200, {'Content-Type': 'text/html'})
res.end(jade.renderFile('.' + req.url, {
filename: '.' + req.url.replace(jadeRe, '')
}))
} else {
req.addListener('end', function () {
fileServer.serve(req, res)
}).resume()
}
}).listen(8080)
Any help would be appreciated.
[1] https://github.com/takahser/immonow
[2] https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction