5

Ionic 2 has deprecated ionic.config.js. ionic.project is now ionic.config.json, and I'm supposed to put my settings in there now. So, following the instructions for ionic proxies for ionic (can't find ionic2 doc for this anywhere), my ionic.config.json now looks like this:

{
  "name": "newapp",
  "app_id": "",
  "v2": true,
  "typescript": true,
  "proxies": [{
    "path": "/api",
    "proxyUrl": "https://api.service.com"
  }]
}

But, this doesn't appear to work.

UPDATE: I seem to be getting the proxied service, but I am still getting CORS errors.

Wayne Werner
  • 1,120
  • 9
  • 7
  • read my answer: http://stackoverflow.com/questions/37763775/no-access-control-allow-origin-header-is-present-upon-ionic2-http-post-request/37779476#37779476, hope this help – vuhung3990 Jun 12 '16 at 22:02

1 Answers1

6

The issue I was having was with the server itself... it is not enough to restart it after changing the configuration. The server must be quit and a new one started with ionic serve to behave correctly.

The above configuration, in ionic.config.json is the correct way to configure a proxy.

Shashank Agrawal
  • 25,161
  • 11
  • 89
  • 121
Wayne Werner
  • 1,120
  • 9
  • 7