2

I'm getting a frustrating "error" while trying to run a simple Node.js app on Heroku. Heroku itself is not reporting an error - the app is up (not crashed, no "Hxx" codes being shown); what I get is this:

heroku[router]: at=info method=GET path=/index.html
host=realsheek.herokuapp.com fwd="24.63.82.165" dyno=web.1 connect=0ms
service=4ms status=404 bytes=33

When i run the app from the browser, it says Cannot GET. I don't know what it's trying to GET. My app is a test bed for a SocialProvider using Mozilla's SocialAPIs. The app itself is a version of the demo from https://github.com/mixedpuppy/socialapi-demo. A couple of bugs were fixed, else this is identical to this demo (i used the repo as is with just the bugs fixed). I have an index.html page which installs the SocialProvider, at which time the server-side app kicks in and does the rest of the magic. It runs fine on localhost, but when I push it up to Heroku, it fails. There were no problems reported with the git push (just the usual "no readme data" warnings).

I am stumped as I just can't see what it's trying to GET; obviously a 404 error suggests a missing page, but the app makes no calls to any HTML pages, and everything that's needed is present (as my run on localhost confirms).

I realize that this isn't a lot to go on, not seeing the actual app and not knowing what it's trying to do. And with no actual error to report - just a 404 status, it obviously could be anything. But I am stumped currently, so if anyone has any insight or suggestion, I'd be most grateful.

4

3 回答 3

9

嗨,我在部署应用程序时也很沮丧。为了部署,您需要确保两件事。

1)使用环境变量设置端口var port=Number(process.env.PORT || 3000);

2) 不要忘记将 Procfile 包含为 web: node app.js(Your start file)

于 2016-04-08T12:48:56.217 回答
0

我有一个类似的问题。解决方案很简单:

1) 确保正确写入 Procfile。它应该看起来像:

web: node index.js

2)将代码推送到heroku后,尝试运行以下命令:

heroku ps:scale web=1

希望有帮助!

于 2014-12-04T05:18:31.030 回答
0

该演示不是节点应用程序,或者至少没有按照 heroku 喜欢的方式与 Procfile 和所有内容一起打包。如果您有一个节点应用程序,那么它会根据其代码(或至少应该)提供静态文件,但 heroku 不是静态页面的标准 Web 服务器(如 Apache 或 nginx 或其他)。Heroku 是为运行 Web 应用程序而构建的,这些应用程序本质上是它们自己的服务器。

如果你让一个节点服务器运行,这个 heroku quickstart for node 应该可以帮助你。 https://devcenter.heroku.com/articles/nodejs

于 2013-06-05T20:54:42.753 回答