我正在使用 Windows Azure 网站来托管 node.js 应用程序。到目前为止,除了我的自定义错误之外,一切都很好。在我的节点应用程序中,我有一个错误处理程序,可以在我的本地计算机上很好地呈现自定义 404 和自定义 500 错误页面。但是,一旦我发布到 azure,当我将 statusCode 设置为除 200 之外的任何值时,它都会覆盖响应。
如果我不将 500 或 404 statusCode 传递给响应,则不会发生这种情况,但我确实希望状态代码能够传递到浏览器。在本地,我得到了自定义错误页面:
但是,在天蓝色网站上,它仅返回一行文本:
由于发生内部服务器错误,该页面无法显示。
我尝试创建自己的 web.config 来覆盖默认配置并禁用自定义错误,但这似乎没有任何效果。这是我的 web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<customErrors mode="off" />
</system.web>
<system.webServer>
<handlers>
<add name="iisnode" path="app.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}"/>
</rule>
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="app.js"/>
</rule>
</rules>
</rewrite>
<iisnode
debuggingEnabled="true"
devErrorsEnabled="true"
debuggerPathSegment="debug"
nodeProcessCommandLine=""%programfiles(x86)%\nodejs\node.exe""
logDirectory="..\..\LogFiles\nodejs"
watchedFiles="*.js;iisnode.yml;node_modules\*;views\*.jade;views\*.ejb;routes\*.js" />
</system.webServer>
</configuration>
我不确定是否iisnode
(将请求路由到 node.js 的 iis 扩展)负责覆盖我的错误页面或者 iis 本身是否负责。有什么建议么?
好吧,没关系,我发现了这个问题。如果其他人遇到同样的问题,只需在下面添加以下内容<system.webServer>
在 web.config 中:
<httpErrors existingResponse="PassThrough" />
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)