我正在尝试添加代理以将源更改为服务器,例如
从http://localhost:4200/api/deaprtment/get/2
到http://localhost:7201/api/department/get/2
请注意,这localhost:4200就是我的角度应用程序运行的地方
是localhost:7201我的 asp.net 服务器运行的内容
我的 proxy-config.json 是
{
"/api": {
"target": "http://localhost:7201",
"secure": false
}
}
Run Code Online (Sandbox Code Playgroud)
它位于 src/proxy-config.json 中
我的 angular.json 是
.
.
.
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "test2:build:production"
},
"development": {
"browserTarget": "test2:build:development",
"proxyConfig": "src/proxy-config.json"
}
},
"defaultConfiguration": "development"
},
.
.
.
Run Code Online (Sandbox Code Playgroud)
当运行时ng serve
它总是给我这个错误:
- 生成浏览器应用程序包(阶段:设置)...发生未处理的异常:代理配置文件 C:\Users\nasse\RiderProjects\Solution2\test2\src\proxy-c onfig.json 包含解析错误:[1, 1] InvalidSymbol 请参阅“C:\Users\nasse\AppData\Local\Temp\ng-T9wrQt\angular-errors.log”了解更多详细信息。
| 归档时间: |
|
| 查看次数: |
713 次 |
| 最近记录: |