Proxy config not working for v4 beta


#1

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.


#2

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"
  }
}

#3

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


#4

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


#5

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.


#6

Hopefully they fix this soon!