2

我在我的 Azure 项目中遇到了一个奇怪的问题,这似乎与服务器的创建方式有关。该项目是使用Basic Azure Node.js Express 4 ApplicationVisual Studio 2013 Ultimate 中的模板创建的。经过一番努力,该项目在本地运行良好,直到我点击浏览器的刷新按钮,该按钮再也不会回来了。

该项目最初是在 WebStorm 中创建的,我没有遇到这个问题。正如我所想,它们之间的差异非常小:在 WebStorm 中,使用了:

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

但在 Visual Studio 中,这是使用的(从 www 文件中的模板创建):

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

当我用 WebStorm 版本替换它时,一切似乎又正常了。谁能解释为什么?

顺便说一句,在我的应用程序中,我没有使用节点视图。相反,我正在使用:

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

会不会和这个问题有关?

4

0 回答 0