使用来自不同服务器上的 Angular 应用程序的集成 windows 身份验证访问受保护的 Web 服务

Access secured Web Services using integrated windows authentication from Angular app on different server

我有一个 Web 服务(目前 localhost:100),它使用 Windows 身份验证,通过 IIS 提供服务,并在 web.config 中设置了 Access Control Allow Origin 属性:

<httpProtocol>
  <customHeaders>
    <add name="Access-Control-Allow-Origin" value="http://localhost:81" />
    <add name="Access-Control-Allow-Credentials" value="true" />
  </customHeaders>
</httpProtocol>

我正在尝试从静态文件(html、css 和 js)提供的 angularJS 应用访问它们,而静态文件 运行 来自不同的服务器我在 IIS 上 运行(当前端口 81):

var productSearch = $resource("http://localhost:100/api/ProductSearch/:id");

但我收到 401(未授权)。

我已将请求站点设置为使用 Windows 身份验证,但没有服务器端,我无法知道它是否有效。它不会将任何用户凭据发送到 Web 服务。

所以我有点傻。我正在寻找的代码行是:

  $http.defaults.withCredentials = true;

这使得它可以在任何地方工作——包括 Node 开发服务器。