【问题标题】:Specifying port 80 in URL gives different result than no port specified在 URL 中指定端口 80 与未指定端口的结果不同
【发布时间】:2019-04-05 14:11:45
【问题描述】:

我在 Heroku 上创建并部署了应用程序。现在通过这个 URL 访问应用程序:https://electricity-manager1.herokuapp.com/api/hello 按预期工作,结果是:

{"express":"Hello From Express"}

但是当我像这样在 URL 中指定端口时:

https://electricity-manager1.herokuapp.com/api/hello:80

我得到不同的结果:主页。

有什么不同?我尝试使用端口 443,但结果相同。 我以为 80 和 443 端口是使用 HTTP 和 HTTPS 协议时的默认端口?

【问题讨论】:

    标签: node.js web heroku server


    【解决方案1】:

    您将端口放置在错误的位置。应该是immediately follow the host, as part of the authority:

    每个 HTTP URL 都符合通用 URI 的语法。 URI 通用语法由五个组件的层次序列组成:

    URI = scheme:[//authority]path[?query][#fragment]
    

    其中权限组件分为三个子组件:

    authority = [userinfo@]host[:port]
    

    这里是为您更新的链接:

    【讨论】:

      猜你喜欢
      • 2014-05-26
      • 2015-03-15
      • 1970-01-01
      • 1970-01-01
      • 2021-11-15
      • 2017-11-12
      • 1970-01-01
      • 2011-05-27
      • 2023-01-25
      相关资源
      最近更新 更多