Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proxy.config.json invalidSymbol [1,1]

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.
like image 390
Mahmoud Nasser Avatar asked Sep 11 '25 19:09

Mahmoud Nasser


1 Answers

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.

like image 85
Fuschi Avatar answered Sep 14 '25 07:09

Fuschi