快速应用程序将500丢到天蓝色

编程入门 行业动态 更新时间:2024-10-26 04:21:31
本文介绍了快速应用程序将500丢到天蓝色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

The following code runs perfectly locally...

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错误.这是我的发现...

But when i deploy it to azure I get a 500 error. Here is my findings...

  • 我已采纳了此建议
  • 尝试过server.js,app.js,目录结构等的所有可能组合.
  • 正在从本地git存储库中部署代码.

    The code is being deployed from a local git repo.

    推荐答案

    Azure Web Apps(网站)仅在端口80和443上侦听.您无法在端口8080上监听.

    Azure Web Apps (web sites) listen on ports 80 and 443 only. You can not listen on port 8080.

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

    You'll need to listen on port process.env.PORT. And you can easily run both locally and in Azure by tweaking your port code to something like:

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

    更多推荐

    快速应用程序将500丢到天蓝色

    本文发布于:2023-11-15 22:56:48,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1598700.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:天蓝色   应用程序   快速

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!