【发布时间】:2026-01-29 16:45:01
【问题描述】:
在使用 ng serve
- 实现prox.conf.json然后运行
ng serve --proxy config proxy.conf.json
{
"/`OSTNextService`": {
"target": "https://localhost/OSTNextService",
"secure": true,
"pathRewrite": {
"^/OSTNextService": ""
},
"`changeOrigin": true`
}
}
将 IIS 标头设置为指定域。在我的情况下 https://localhost:4200
-
设置服务 global.asax 文件
没有什么对我有用,并且出现像
这样的错误访问 XMLHttpRequest 在 'https://localhost/OSTNextService/OSTPortalService.svc/GetUserName' 来自原点“https://localhost:4200”已被 CORS 策略阻止: 响应中“Access-Control-Allow-Origin”标头的值 当请求的凭证模式为 '包括'。发起请求的凭证模式 XMLHttpRequest 由 withCredentials 属性控制。
当我在 IIS 中托管应用程序并将 dist 文件夹映射到它时,一切正常。但是每次我更改构建应用程序所需的 .ts 文件几乎都是双倍的浪费。请通过建议我在这里缺少什么来提供帮助。
【问题讨论】:
-
您的本地主机是否在安全协议上运行?
标签: angular api iis cors localhost