Azure node.js未收到POST请求

时间:2017-07-26 17:01:52

标签: node.js azure iis web-config

我有一个可在本地运行的应用程序,但当我将其部署到azure POST请求时会收到404响应。各种答案表明我需要编辑我的web.config,但我不知道需要改变什么。

如果相关:我的POST是服务器上名为/ receive的路径,应该由server.js处理



<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your Node.js application, please visit
  http://go.microsoft.com/fwlink/?LinkId=290972
  -->
<configuration>
  <appSettings>

    <!--
    <add key="StorageAccountName" value="" />
    <add key="StorageAccountKey" value="" />
    <add key="ServiceBusNamespace" value="" />
    <add key="ServiceBusIssuerName" value="" />
    <add key="ServiceBusIssuerSecretKey" value="" />
    -->
  </appSettings>
  <system.webServer>
    <!-- mimeMap enables IIS to serve particular file types as specified by fileExtension. -->
    <staticContent>
      <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
    </staticContent>

    <modules runAllManagedModulesForAllRequests="false" />

    <!-- Web.Debug.config adds attributes to this to enable remote debugging when publishing in Debug configuration. -->
    <iisnode watchedFiles="web.config;*.js" />

    <!-- Remote debugging (Azure Website with git deploy): Comment out iisnode above, and uncomment iisnode below. -->
    <!--<iisnode watchedFiles="web.config;*.js" 
      loggingEnabled="true" 
      devErrorsEnabled="true" 
      nodeProcessCommandLine="node.exe &#45;&#45;debug"/>-->

    <!-- indicates that the server.js file is a Node.js application 
    to be handled by the iisnode module -->
    <handlers>
      <add name="iisnode" path="server.js" verb="*" modules="iisnode" />

      <!-- Remote debugging (Azure Website with git deploy): Uncomment NtvsDebugProxy handler below. 
      Additionally copy Microsoft.NodejsTools.WebRole to 'bin' from the Remote Debug Proxy folder.-->
      <!--<add name="NtvsDebugProxy" path="ntvs-debug-proxy/eee3ec35-9835-494f-a07c-dc2f85619df0" verb="*" resourceType="Unspecified" 
        type="Microsoft.NodejsTools.Debugger.WebSocketProxy, Microsoft.NodejsTools.WebRole"/>-->
    </handlers>
    <rewrite>
      <rules>
        <clear />
        <!-- Remote debugging (Azure Website with git deploy): Uncomment the NtvsDebugProxy rule below. -->
        <!--<rule name="NtvsDebugProxy" enabled="true" stopProcessing="true"> 
          <match url="^ntvs-debug-proxy/.*"/> 
        </rule>-->

        <!-- Don't interfere with requests for node-inspector debugging -->
        <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^server.js\/debug[\/]?" />
        </rule>

        <rule name="app" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="iisnode.+" negate="true" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
          <action type="Rewrite" url="server.js" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>

  <!-- Remote debugging (Azure Website with git deploy): uncomment system.web below -->
  <!--<system.web> 
    <httpRuntime targetFramework="4.5"/> 
    <customErrors mode="Off"/> 
  </system.web>-->
</configuration>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

我在我的测试node.js应用程序中测试了你的web.config文件,一切正常。它应该是导致您的问题的任何其他原因。您能否提供有关您的申请的更多信息,例如:您如何部署到Azure Web Apps,您的结构是什么以及与帖子功能相关的任何关键代码段。这些可以帮助社区检测到任务。

与此同时,您可以尝试利用 Log Stream 工具在Azure应用程序运行时跟踪应用程序的所有信息和标准输出。

您可以登录Azure门户,导航至Azure Apps刀片,单击诊断日志 =&gt;启用应用程序日志记录(文件系统),然后单击日志流以打开该工具。