【发布时间】:2016-10-20 06:38:33
【问题描述】:
我正在构建一个应用程序,我正在使用 nodejs express 来执行 rest api 服务。 我使用 iisnode 模块在 Windows Server 2012 上托管了该应用程序。一切都很完美。 问题是当我从节点应用程序返回 404(未授权)消息时,端点正在接收带有 iis 错误页面的 401 http 状态。 有没有其他方法可以解决这个问题。
这是我的 webconfig 文件
<!-- indicates that the hello.js file is a node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="app.js" verb="*" modules="iisnode" />
</handlers>
<!-- use URL rewriting to redirect the entire branch of the URL namespace
to hello.js node.js application; for example, the following URLs will
all be handled by hello.js:
http://localhost/node/express/myapp/foo
http://localhost/node/express/myapp/bar
-->
<rewrite>
<rules>
<rule name="/">
<match url="/*" />
<action type="Rewrite" url="app.js" />
</rule>
</rules>
</rewrite>
我在 nodejs 应用中的代码如下
if(clienttoken!=servertoken)
{
res.json(401, 'unauthorized');
res.end();
}
提前致谢
【问题讨论】:
标签: asp.net node.js express iis iisnode