How to use a Proxy to HTTPS services?

Ok, it really seems that ionic currently has no support for this. This is how you have to modify Ionic to make things work:

  1. find the Ionic serve.js file, i.e. on a mac: /usr/share/nodejs/node-v0.12.0/lib/node_modules/ionic/lib/serve.js

  2. search for this code:

    var opts = url.parse(proxy.proxyUrl);
    if(proxy.proxyNoAgent)
        opts.agent = false;
    
  3. Add this line after the if statement:

    var opts = url.parse(proxy.proxyUrl);
    if(proxy.proxyNoAgent)
        opts.agent = false;
    opts.rejectUnauthorized = !(proxy.rejectUnauthorized === false);
    
  4. Add rejectUnauthorized = false to your proxy configuration:

    {
        "name": "proxy-example", 
        "app_id": "",
        "proxies": [
            {
                "path": "/api",
                "proxyUrl": "https://localhost:8181/api",
                "rejectUnauthorized" : false
            }
        ]
    }
    

This works just fine, because Ionic uses internally proxy-middleware which supports any of the https request options, for more information see here.
rejectUnauthorized is a setting from proxy-middleware :slight_smile:

That works like a charm. I hope the Ionic guys will merge the one line of code into their distribution so that everyone can use this :slight_smile: