Azure iisnode angularJS 1.x应用程序无限循环(使用$http时)

Azure iisnode angularJS 1.x应用程序无限循环(使用$http时),angularjs,azure,iisnode,Angularjs,Azure,Iisnode,我使用index.html中的iisnode/Azure为angular 1.x应用程序提供服务。路由工作正常,但每当我加载任何进行$http资源调用的视图时,它似乎进入无限循环。api托管在不同的实例上。我已经在postman中测试了命中实例apiBase/in,它返回了预期的响应。iisnode的Myweb.config如下所示: <configuration> <system.webServer> <rewrite> <ru

我使用index.html中的iisnode/Azure为angular 1.x应用程序提供服务。路由工作正常,但每当我加载任何进行$http资源调用的视图时,它似乎进入无限循环。api托管在不同的实例上。我已经在postman中测试了命中实例apiBase/in,它返回了预期的响应。iisnode的Myweb.config如下所示:

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
       <clear />

    <rule name="AngularJS Conditions" stopProcessing="true">
      <match url="(css/.*|images/.*|scripts/.*)" />
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
      <action type="None" />
    </rule>

    <rule name="AngularJS Wildcard" enabled="true">
      <match url="(.*)" />
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
      <action type="Rewrite" url="index.html" />
    </rule>

  </rules>
</rewrite>


任何帮助都非常有用。iisnode/Azure非常新。

实际上,如果您在Azure Web App上运行纯angularJs SPA,则无需配置
Web.config
来强制iisnode执行您的应用程序。因为angularJs应用程序完全是纯javascript应用程序,通过解释器在客户端浏览器上运行。并且,您在IIS中配置的重写模式可能会破坏anguarJs应用程序中的路由事件

您可以尝试删除
web.config
文件并重新启动Azure web应用程序

此外,由于我无法在我这方面复制您的问题,如果您方便的话,请在GitHub或其他任何地方提供问题项目回购,以便我们检测问题

更新 如果您使用angularjs route provider的
HTML5模式
,这可能是一个常见问题

请尝试使用以下内容修改您的
web.config

<configuration>
    <system.webServer>
     <rewrite>
      <rules>
        <rule name="AngularJS Routes" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
          </conditions>
          <action type="Rewrite" url="/" />
        </rule>
      </rules>
    </rewrite>
    </system.webServer>
</configuration>

实际上,如果您在Azure Web App上运行纯angularJs SPA,则无需配置
Web.config
来强制iisnode执行您的应用程序。因为angularJs应用程序完全是纯javascript应用程序,通过解释器在客户端浏览器上运行。并且,您在IIS中配置的重写模式可能会破坏anguarJs应用程序中的路由事件

您可以尝试删除
web.config
文件并重新启动Azure web应用程序

此外,由于我无法在我这方面复制您的问题,如果您方便的话,请在GitHub或其他任何地方提供问题项目回购,以便我们检测问题

更新 如果您使用angularjs route provider的
HTML5模式
,这可能是一个常见问题

请尝试使用以下内容修改您的
web.config

<configuration>
    <system.webServer>
     <rewrite>
      <rules>
        <rule name="AngularJS Routes" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
          </conditions>
          <action type="Rewrite" url="/" />
        </rule>
      </rules>
    </rewrite>
    </system.webServer>
</configuration>


这有点正确,但当我直接说baseUrl/routeName(即从链接或硬刷新)时,Azure返回-您正在查找的资源已被删除、名称已更改或暂时不可用。您是说整个angularjs应用程序都响应了404错误吗,或者您试图通过
templateUrl
从角度路由提供程序调用的视图模板响应了404错误?你能通过模板的url直接浏览模板吗?你能告诉我视图模板的扩展吗?不,我很确定这是azure错误。我可以按预期精确地点击根
/
url和角度负载。我也可以按预期在angular应用程序中进行操作,但如果我直接进入路线,如
/transactions
(例如在新选项卡中或硬刷新,则我会收到该错误),因为它在我这边(包括angular route模块)工作正常。您能提供您的存储库吗?不确定我将如何向您提供我的存储库。我将无法与您共享它,因为它包含敏感信息?你需要我的回购协议做什么?文件夹结构或特定文件?这有点正确,但当我直接说baseUrl/routeName(即从链接或硬刷新)时,Azure返回-您正在查找的资源已被删除、名称已更改或暂时不可用。您是说整个angularjs应用程序响应404错误,或者您试图通过
templateUrl
从角度路由提供程序调用的视图模板响应了404错误?你能通过模板的url直接浏览模板吗?你能告诉我视图模板的扩展吗?不,我很确定这是azure错误。我可以按预期精确地点击根
/
url和角度负载。我也可以按预期在angular应用程序中进行操作,但如果我直接进入路线,如
/transactions
(例如在新选项卡中或硬刷新,则我会收到该错误),因为它在我这边(包括angular route模块)工作正常。您能提供您的存储库吗?不确定我将如何向您提供我的存储库。我将无法与您共享它,因为它包含敏感信息?你需要我的回购协议做什么?文件夹结构还是特定的文件?