Search code examples
javascriptangularjsnode.jsazureloopback

Cannot GET / Node.js when publish with azure


i just have a problem when i publish to azure . it said: Cannot GET / when i open the website .

i using static site with node.js , angular.js, and loopback(API)

here my client side (site.js):

var express = require('express'),
    app = express();

app.use(express.static(__dirname + '/Public'));

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

There is index.html inside Public Folder .

this is my Package.json :

{
  "name": "angular-site",
  "version": "1.0.0",
  "description": "static server to server Node.js",
  "main": "site.js",
  "author": "Jordan Leonardi",
  "dependencies": {
    "express": "^4.8.5"
  }
}

when i tried to localhost, its look Fine, but when i tried to Azurewebsites its give me back an error " Cannot GET / " . .


Solution

  • Also, you should use process.env.PORT || 1338 instead of custom port 1338 when you deploy your app to cloud service such as Azure App Service, Heroku etc.