Proxy config not working for v4 beta

Setting the proxies list config in ionic.config.json doesn’t seem to work (at least not like v3).

  • Tried following the guide at https://beta.ionicframework.com/docs/cli/overview/#using-a-proxy. Set ionic config set -g proxy http://proxy.example.com:8888 and export IONIC_HTTP_PROXY="http://proxy.example.com:8888" without luck

  • Also tried creating an Angular proxy.conf.json and setting it in angular.json’s ionic-cordova-server config : "proxyConfig": "proxy.conf.json" without luck as well.

1 Like

In angular.json you maybe added it in the wrong place, add it to

"serve": {
      "builder": "@angular-devkit/build-angular:dev-server",
      "options": {
        "browserTarget": "app:build",
        "proxyConfig": "proxy.conf.json"
      },
      "configurations": {
        "production": {
          "browserTarget": "app:build:production"
        }
      }
    }

it works fine for me

my proxy.conf.json (root of my project, v1 is the path for all my queries in my server)

{
 "/v1": {
    "target": "https://mydomain.com",
    "changeOrigin": true,
    "secure": false,
    "logLevel": "debug"
  }
}
4 Likes

Working on browser but not working on android. Please have a look asap if possible.

1 Like

<plugin name=“cordova-plugin-ionic-webview” spec="^2.1.4">

Somehow this solution is not proxying my requests correctly. My ionic setup is as follows:

ionic (Ionic CLI) : 4.3.0 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.0-beta.15
@angular-devkit/build-angular : 0.8.7
@angular-devkit/schematics : 0.8.7
@angular/cli : 6.2.7
@ionic/angular-toolkit : 1.1.0

My proxy.conf.json looks like below:
{
“/v1”: {
“target”: “https://www.pingaze.com/”,
“changeOrigin”: true,
“secure”: false,
“logLevel”: “debug”
}
}

Anf angular.json as follows:

“serve”: {
“builder”: “@angular-devkit/build-angular:dev-server”,
“options”: {
“browserTarget”: “app:build”,
“proxyConfig”: “proxy.conf.json”
},

But when I call the API on my server I still get the following error:
status: 404, statusText: “Not Found”, url: “http://localhost:8100/v1/getfilelist.php”, ok: false, name: “HttpErrorResponse”, message: “Http failure response for http://localhost:8100/v1/getfilelist.php: 404 Not Found”, error: “No input file specified.\n” }

As you can see, the request is still going to localhost:8100 instead of my server configured in the proxy.conf.json.

Any help would be highly appreciated.

3 Likes

Hopefully they fix this soon!

Hi, Where can i locate angular.json file?:no_mouth: I am new to this, please help :slightly_smiling_face:

in the root directory of your Ionic v4 project

Is there a workaround for this? proxyConfig is working on web builds but still not working on compiled ios or android apps :frowning:

ionic CLI 4.10.3
@angular/core": “7.2.15”
@ionic/angular": “4.4.0”

1 Like