【问题标题】:http or https in request path to a node server creates an error节点服务器的请求路径中的 http 或 https 会产生错误
【发布时间】:2018-02-01 14:53:33
【问题描述】:

我正在尝试使 corsanywhere 在 Azure 上工作,如果我请求这样的内容,它实际上可以工作:

https://myserver.azurewebsites.net/www.remoteserver.com/query=john

但是如果我调用它,我会得到一个 500 错误并且我不知道如何跟踪它(在这种情况下,日志中不会产生错误):

https://myserver.azurewebsites.net/http://www.remoteserver.com/query=john

这种请求在 corsanywhere 演示站点上或当我在我的开发机器上运行我的节点应用程序时效果很好。

更新: Azure 上的节点需要一个 web.config 文件。这是我的:

<configuration>
<system.webServer>
      <handlers>
        <add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
      </handlers>
      <rewrite>
        <rules>
          <rule name="DynamicContent">
             <match url="/*" />
             <action type="Rewrite" url="server.js"/>
          </rule>
        </rules>
      </rewrite>
</system.webServer>
</configuration>

我想知道这是否是罪魁祸首......

感谢您的帮助

【问题讨论】:

  • 你是如何运行你的节点应用程序的?我的意思是node index.js、pm2 start index.js、nodemon index.js等
  • node server.js 在 package.json 中被提及
  • 您应该在控制台中看到您的错误,您在其中写了node server.js
  • 嗯,这在 Azure 上运行...

标签: node.js azure url-rewriting cors-anywhere


【解决方案1】:

在 Azure 应用服务 (Windows OS) 中,字符 :/ 不允许出现在 URL 路径中。之前在 SO 上讨论过这个问题:Azure websites throw 500 error when there is a colon in the URL

您可以尝试@TimBunting 的答案中的解决方案,或者将您的应用程序托管在Linux App Service 上。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-04
    • 2021-07-12
    • 1970-01-01
    • 2015-08-28
    • 1970-01-01
    • 2019-01-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多