Windows Azure的网站是压倒我的404和500错误页面在我的Node.js应用 [英] Windows Azure Websites is overriding my 404 and 500 error pages in my node.js app

查看:716
本文介绍了Windows Azure的网站是压倒我的404和500错误页面在我的Node.js应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的Windows Azure网站举办的Node.js应用。到目前为止,一切都只是我的自定义错误很大。在我的节点应用程序我有呈现一个自定义的404和500的自定义错误页,我的本地机器就好了错误处理程序。但是,只要我发布到Azure它覆盖的反应,当我设置状态code到任何东西,除了200。

I am using Windows Azure Websites to host a node.js application. So far everything is great except for my custom errors. In my node app I have an error handler that renders a custom 404 and custom 500 error page just fine on my local machine. However, as soon as I publish to azure it overrides the response when I set the statusCode to anything except 200.

如果我没有500或404状态code传递到响应,那么这不会发生,但我想要的状态codeS,使其到浏览器。在当地得到我的自定义错误页就好了:

If I don't pass the 500 or 404 statusCode to the response then this does not happen, but I do want the status codes to make it to the browser. Locally I get my custom error page just fine:

然而,在蔚蓝的网站它只返回单个文本行:

However, on azure websites it only returns a single line of text:

无法显示页面,因为发生内部服务器错误。

The page cannot be displayed because an internal server error has occurred.

我试图创造我自己的web.config覆盖默认的禁用自定义错误,但似乎没有任何效果。这里是我的web.config:

I tried creating my own web.config to override the default one with custom errors disabled but that didn't seem to have any effect. Here is my 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="&quot;%programfiles(x86)%\nodejs\node.exe&quot;"
            logDirectory="..\..\LogFiles\nodejs"
            watchedFiles="*.js;iisnode.yml;node_modules\*;views\*.jade;views\*.ejb;routes\*.js" />
    </system.webServer>
</configuration>

我不知道,如果 iisnode (扩展为IIS的请求路由到的node.js)负责重写我的错误页面,或如果IIS本身负责。有什么建议?

I'm not sure if iisnode (the extension for iis that routes requests to node.js) is responsible for overriding my error pages or if iis itself is responsible. Any suggestions?

推荐答案

好没关系,我发现这个问题。其他人是否有相同的问题简单地添加在以下&LT; system.webServer&GT; 在web.config中:

Well nevermind, I found the issue. If anyone else is having the same problem simply add the following under <system.webServer> in web.config:

<httpErrors existingResponse="PassThrough" />

这篇关于Windows Azure的网站是压倒我的404和500错误页面在我的Node.js应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆