【问题标题】:Express Applications throwing 500 on azureExpress Applications 在 azure 上抛出 500
【发布时间】:2016-03-21 03:43:47
【问题描述】:

以下代码在本地完美运行...

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

app.get('/', function (req, res) {
    res.send("Hello World");
});

var port = 8080;

app.listen(port, function () {
    console.log('Server started and is listening on port ' + port);
});

但是当我将它部署到天蓝色时,我得到一个 500 错误。这是我的发现...

  1. 我已经拿了这个advice
  2. 已经尝试了 server.js、app.js、目录结构等所有可能的组合。

代码正在从本地 git 存储库部署。

【问题讨论】:

标签: node.js azure azure-web-app-service


【解决方案1】:

Azure Web 应用程序(网站)仅侦听端口 80 和 443。 8080端口不能监听。

您需要监听端口process.env.PORT。通过将端口代码调整为以下内容,您可以轻松地在本地和 Azure 中运行:

var port = process.env.PORT || 8080;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多