angular cli + windows 身份验证后端

标签 angular windows-authentication

我创建了一个 Angular CLI 项目,其中包含对包含 Web API 服务的后端项目的代理引用。

launchSettings.json(后端项目):

...
  "iisSettings": {
    "windowsAuthentication": true,
    "anonymousAuthentication": false,
    "iisExpress": {
      "applicationUrl": "http://localhost:10863/",
      "sslPort": 0
    }
  },
...

proxy.conf.json(前端项目):

{
  "/api": {
    "target": "http://localhost:10863",
    "secure": false,
    "logLevel": "debug"
  }
}

package.json(前端项目):

...
"scripts": {
    "ng": "ng",
    "start": "start http://localhost:4200 && ng serve --proxy-config proxy.conf.json",
    "build": "ng build --prod --output-path=..\\CoreTest\\wwwroot",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
...

然后我启动后端并通过运行 npm start 启动 Kestrel 网络服务器。使用 angular2 服务,我对其中一项后端服务执行 http-get 操作。由于后端服务在带有 Windows 身份验证的 IISExpress 中运行 (我想要 windows 身份验证),我收到 401 错误。

我可以执行 npm run build 并浏览到我的 IISExpress url 并加载 ng build 发布的 index.html 但我想使用 ng serve 方法,因为开发更顺利,因为 ng在内存中服务。

我的问题是:如何在开发过程中将 Angular CLI 与 Windows 身份验证结合使用?

最佳答案

就其值(value)而言,更好的解决方案是使用代理 js 文件 https://github.com/angular/angular-cli/issues/5627#issuecomment-289381319

关于angular cli + windows 身份验证后端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42981555/

相关文章:

java - 通过 JDBC 从 Linux 计算机使用 Windows 身份验证连接到 SQL Server

c# - 遇到 SignInAsync 问题

web-services - 仅当 web svcs 客户端与 IIS 服务器位于同一台计算机上时,Windows 集成身份验证才会失败

c# - MVC - 混合身份验证 - OWIN + Windows 身份验证

javascript - 从 Angular 2+ 中的同级组件访问元素

javascript - 如何在 JBoss 服务器中使用 typescript 部署 Angular 2?

javascript - Angular/CLI : How to change the port for auto reload?

angular - 错误类型错误 : Cannot read property 'invalid' of undefined angular 4

Angular @Input 不适用于 Bootstrap 组件

asp.net-core - 在 Active Directory 环境中生成 JWT