Proxy config for different environments


#1

I am new to ionic and I try to setup a proxy configuration for different environments. I have several environment-specific config files in place which get loaded using webpack and an environment variable which is set before ionic is served.

Everything works as expected but I don’t know how to solve following issue:
My proxy configuration (ionic.config.json) looks like this:

"proxies": [
    {
      "path": "/api",
      "proxyUrl": "https://dv.mydomain.com/api",
      "rejectUnauthorized": false
    }
  ]

and my http call looks like this:
return this.http.get<User[]>(ENV.apiUrl + '/api/users')

I have to remove ENV.apiUrl because otherwise the pattern specified in the proxy config doesn’t get matched, but if I do so, I cannot distinguish between different environments anymore. I have tried to add the domain to the path of the proxy configuration, which did not work.

Is there a way to solve this issue?