【发布时间】:2017-03-23 16:17:17
【问题描述】:
我创建了一个 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 serve 在内存中工作,因此开发更加顺畅。
我的问题是:如何在开发过程中使用 Angular CLI 和 Windows 身份验证?
【问题讨论】:
标签: angular windows-authentication