javascriptibm-cloudibm-cloud-tools

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


I am new in Bluemix. So far I created web app,got its code and run this app in localhost. Everything works good. The app uses AngularJs and json-server. Later on I will Node.js too. To run it I use 'json-server --watch db.json'. The json file contains various json arrays and objects. And this is my list of links.

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

My guess is that all those links should be changed to a live route instead of using localhost. In my dashboard I can see the name's app the route(theo-larissa.mybluemix.net) and it's state with is stopped. Now when I am trying to start the app,I get this message

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

Any ideas how to fix this?

Thanks in advance,

Theo.


Solution

  • What do your console logs for theo-larissa.mybluemix.net show? One of the really common deployment mistakes is to leave the port hard-coded in your application when you deploy it to Bluemix. You can't do that; you have to allow Bluemix to specify the port your application will use. You would do that, for example, by encoding something like the following when you create the server:

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

    If you wanted to make this fully automated, you could include code like the following:

    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);});
      }