1

我是 Bluemix 的新手。到目前为止,我创建了 Web 应用程序,获取了它的代码并在 localhost 中运行了这个应用程序。一切正常。该应用程序使用 AngularJs 和 json-server。稍后我也会使用 Node.js。要运行它,我使用'json-server --watch db.json'。json 文件包含各种 json 数组和对象。这是我的链接列表。

http://localhost:3000/news
http://localhost:3000/events
http://localhost:3000/city
http://localhost:3000/administration
http://localhost:3000/deputy_mayors
http://localhost:3000/alcazar_park
http://localhost:3000/feedback

我的猜测是所有这些链接都应该更改为实时路由,而不是使用 localhost。在我的仪表板中,我可以看到名称的应用程序路由(theo-larissa.mybluemix.net),并且它的状态已停止。现在,当我尝试启动应用程序时,我收到此消息

404 Not Found: Requested route ('theo-larissa.mybluemix.net') does not exist.

任何想法如何解决这一问题?

提前致谢,

西奥。

4

2 回答 2

1

您的 theo-larissa.mybluemix.net 控制台日志显示什么?真正常见的部署错误之一是在将应用程序部署到 Bluemix 时将端口硬编码在应用程序中。你不能那样做;您必须允许 Bluemix 指定您的应用程序将使用的端口。例如,您可以通过在创建服务器时对以下内容进行编码来做到这一点:

var server = app.listen(app.get('port'), function()
  {console.log('Listening on port %d', server.address().port);});

如果你想让这个完全自动化,你可以包含如下代码:

app.set('port', appEnv.port);
app.set('appName', 'theo-larissa');

if (cfenv.getAppEnv().isLocal == true)
   {http.createServer(app).listen(app.get('port'),
     function(req, res) {console.log(app.get('appName')+' is listening locally on port: ' + app.get('port'));});
  }
  else
  {
    var server = app.listen(app.get('port'), function() {console.log('Listening on port %d', server.address().port);});
  }
于 2017-06-06T15:06:43.043 回答
-1
app.set('port', appEnv.port);
app.set('appName', 'theo-larissa');

if (cfenv.getAppEnv().isLocal == true)
   {http.createServer(app).listen(app.get('port'),
     function(req, res) {console.log(app.get('appName')+' is listening locally on port: ' + app.get('port'));});
  }
  else
  {
    var server = app.listen(app.get('port'), function() {console.log('Listening on port %d', server.address().port);});
  }
于 2018-03-04T06:05:22.713 回答