【问题标题】:New Sails.js app gets infinite redirect in Heroku新 Sails.js 应用程序在 Heroku 中获得无限重定向
【发布时间】:2018-10-26 14:29:28
【问题描述】:

我使用 Sails.js 版本创建了一个空应用程序。 1.0.2。我使用了“sails new”命令的“Web App”选项。在开发环境和生产环境中,在本地主机上启动时,它都可以正常工作。

接下来,我想把这个应用程序放到 Heroku 中。

我做了什么:

  • 在 Heroku 中使用“heroku create”创建了新应用;
  • 在我的应用程序根目录中初始化了新的 git 存储库;
  • 在我的应用根目录中创建了 Procfile,文本为:“web: npm start”
  • 更改了生产环境配置(在 \config\env\production.js 中):
  • 使用“heroku git:remote -a myappname”为我的仓库设置 heroku 远程
  • 使用“git push heroku master”添加、提交并将我的 repo 推送到 Heroku

它成功构建并带有一些警告,但最糟糕的是应用程序无法运行。每个请求都会导致带有 heroku[router] 的重定向循环到相同的地址。

这是 Heroku 日志的一部分:

2018-05-16T12:52:25.991036+00:00 app[web.1]: debug: -------------------------------------------------------
2018-05-16T12:52:25.991290+00:00 app[web.1]: debug: :: Wed May 16 2018 12:52:25 GMT+0000 (UTC)
2018-05-16T12:52:25.991366+00:00 app[web.1]: debug: Environment : production
2018-05-16T12:52:25.991441+00:00 app[web.1]: debug: Port        : 37749
2018-05-16T12:52:25.991589+00:00 app[web.1]: debug: -------------------------------------------------------
2018-05-16T12:52:26.645022+00:00 heroku[web.1]: State changed from starting to up
2018-05-16T12:52:27.762757+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=ee575a91-305f-4518-af9f-537ceccbc3cf fwd="83.45.25.57" dyno=web.1 connect=2ms service=48ms status=302 bytes=523 protocol=https
2018-05-16T12:52:28.039174+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=980d6e72-b03c-4704-af97-56c7f9debc8b fwd="83.45.25.57" dyno=web.1 connect=0ms service=9ms status=302 bytes=360 protocol=http
2018-05-16T12:52:28.185571+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=b46a235f-fbf7-4404-a4b7-0a95bb1a0254 fwd="83.45.25.57" dyno=web.1 connect=1ms service=5ms status=302 bytes=360 protocol=http
2018-05-16T12:52:28.339593+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=03bbd460-3200-4158-a555-33c20262a212 fwd="83.45.25.57" dyno=web.1 connect=2ms service=7ms status=302 bytes=360 protocol=http
2018-05-16T12:52:28.484756+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=af7303b1-f04c-431b-93b5-9e8b148a6721 fwd="83.45.25.57" dyno=web.1 connect=1ms service=4ms status=302 bytes=360 protocol=http
2018-05-16T12:52:28.637541+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=1535454e-58b0-41d2-821d-317d7ebabeeb fwd="83.45.25.57" dyno=web.1 connect=4ms service=8ms status=302 bytes=360 protocol=http
2018-05-16T12:52:28.788965+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=559d3426-78b9-4b65-8063-c44eb728d825 fwd="83.45.25.57" dyno=web.1 connect=1ms service=6ms status=302 bytes=360 protocol=http
2018-05-16T12:52:28.936187+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=e4ad129d-746b-490c-9d0d-c77966b98d46 fwd="83.45.25.57" dyno=web.1 connect=1ms service=7ms status=302 bytes=360 protocol=http
2018-05-16T12:52:29.082496+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=92a66cab-344e-410d-9ebf-8c8bddec80bd fwd="83.45.25.57" dyno=web.1 connect=2ms service=5ms status=302 bytes=360 protocol=http
2018-05-16T12:52:29.233773+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=92f3734c-6e37-48d6-9849-807b53f1e1f7 fwd="83.45.25.57" dyno=web.1 connect=1ms service=5ms status=302 bytes=360 protocol=http

尝试将 custom.baseUrl 设置为 HTTP 和 HTTPS,没有区别。 哪里出了问题?

【问题讨论】:

    标签: node.js heroku sails.js


    【解决方案1】:

    @marvin,你不需要在 heroku 中创建 Procfile。 就在您部署应用时,它会自动运行并设置环境生产。

    【讨论】:

    • 这有帮助吗?我有同样的问题。 @marvin
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-15
    • 1970-01-01
    • 2019-07-06
    • 1970-01-01
    • 2013-08-27
    • 2018-05-12
    • 1970-01-01
    相关资源
    最近更新 更多