简体   繁体   English

在Azure Node.js Web应用程序上运行angularjs 1.6.x,长网址导致404服务器错误

[英]Running angularjs 1.6.x on azure node.js webapp, long url causes a 404 server error

I currently have two azure web apps deployed running on a node.js express server using angularjs (1.6.x) for my MVC (ui-router as well). 我目前在我的MVC(以及UI路由器)上使用angularjs(1.6.x)在node.js Express服务器上运行了两个部署的Azure Web应用程序。 My first web app links directly to the other, passing an access token in the query params for authentication. 我的第一个Web应用程序直接链接到另一个Web应用程序,并在查询参数中传递访问令牌以进行身份​​验证。 This all works fine while running from my localhost; 从我的本地主机运行时,一切正常; however, once deployed to Azure I am receiving a 404 not found error. 但是,一旦部署到Azure,我会收到404 not found错误。 The URL is roughly 1700 characters long. 该URL大约1700个字符长。

The access token is safe for URLs, as are my other two query params (which are much shorter). 访问令牌对于URL是安全的,其他两个查询参数(都短得多)也是如此。 Surprisingly (to me), if I shorten the value of my "token" parameter my angular application loads no problem when on Azure. 令我惊讶的是,如果我缩短“令牌”参数的值,则在Azure上安装我的角度应用程序就不会出现问题。

Is there some setting in Azure or iisnode.yml that can help with this problem? Azure或iisnode.yml中是否有可以帮助解决此问题的设置? It seems like it's the length of my URL that is causing the issue. 似乎是造成问题的网址长度。

Azure uses IIS host your web app. Azure使用IIS托管您的Web应用程序。 And the <requestLimits> element specifies limits on HTTP requests that are processed by IIS. 并且<requestLimits>元素指定对由IIS处理的HTTP请求的限制。 So to fix your issue, you can specify the maximum length of the query string, in bytes. 因此,要解决您的问题,您可以指定查询字符串的最大长度(以字节为单位)。 The default value is 2048 . 默认值为2048

Please add the following to your web.config : 请将以下内容添加到您的web.config

<system.webServer>
  <security>
    <requestFiltering>
      <requestLimits maxQueryString="32768"/>
    </requestFiltering>
  </security>
</system.webServer>

More detailed information, you can refer to https://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits . 有关更多详细信息,您可以参考https://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM