I am trying to add proxy to change the origin to the server like
from http://localhost:4200/api/deaprtment/get/2
to http://localhost:7201/api/department/get/2
note that localhost:4200
is what my angular app run in
and localhost:7201
is what my asp.net server run in
my proxy-config.json is
{
"/api": {
"target": "http://localhost:7201",
"secure": false
}
}
it's in src/proxy-config.json
my angular.json is
.
.
.
"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"
},
.
.
.
and when run ng serve
it's always give me that error:
- Generating browser application bundles (phase: setup)...An unhandled exception occurred: Proxy configuration file C:\Users\nasse\RiderProjects\Solution2\test2\src\proxy-c onfig.json contains parse errors: [1, 1] InvalidSymbol See "C:\Users\nasse\AppData\Local\Temp\ng-T9wrQt\angular-errors.log" for further details.
Just had the same error, when updating to angular 14. Change the encoding of the proxy.config.json file from UTF-8-BOM to UTF-8 worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With