我正在尝试添加代理来更改服务器的原点,如
来自http://localhost:4200/api/deaprtment/get/2
转到http://localhost:7201/api/department/get/2
请注意,localhost:4200是我的角应用程序所运行的
localhost:7201是我的asp.net服务器运行的地方。
我的代理-config.json是
{
"/api": {
"target": "http://localhost:7201",
"secure": false
}
}它位于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"
},
.
.
.当运行ng serve时,总是会给我一个错误:
生成浏览器应用程序包(阶段:安装)的C:\Users\nasse\RiderProjects\Solution2\test2\src\proxy-c
发布于 2022-09-20 13:58:01
只是有同样的错误,当更新到角14。将proxy.config.json文件的编码从UTF-8-BOM更改为UTF-8为我工作。
https://stackoverflow.com/questions/73774778
复制相似问题