2

I ran into strange problem in my Azure project which seems to be related to how server is created. The project was created using the Basic Azure Node.js Express 4 Application template in Visual Studio 2013 Ultimate. After some struggle, the project runs fine locally, until I hit the browser's refresh button which never comes back.

The project was initially created in WebStorm and I didn't have this problem. As I figured, the difference between them is very minimal: In WebStorm, this is used:

var server = http.createServer(app);
server.listen(process.env.PORT, process.env.IP);

But in Visual Studio, this is used (created from template in www file):

app.set('port', process.env.PORT || 3000);
var server = app.listen(app.get('port'), function() {
    console.log('express server listening on port ' + server.address().port);
});

When I replace this with the WebStorm version, everything seems to work fine again. Can anybody explain why?

By the way, in my app, I'm not using node views. Instead, I'm using:

app.set("view options", { layout: false });
app.all('*', function (req, res, next) {
    res.sendFile(__dirname + "/public/index.html"); // Just send the index.html for other files to support HTML5Mode
});

Could it be related to this problem?

newman
  • 6,841
  • 21
  • 79
  • 126

0 Answers0