Ionic proxy just 404 errors at localhost

I’m trying to get the proxy to work, but it is apparently not matching on the service request. I’m attempting to hit a rest-service running in a VM on my machine. Both are wifi-ed to the same subnet.

here is the trace from ionic serve showing it took the mapping:

[15:26:32]  Proxy added:/ui/getList => http://192.168.10.110:8888/ui/getList 
[15:26:32]  Proxy added:/ui/create => http://192.168.10.110:8888/ui/create
[15:26:32]  Proxy added:/ui/getOverviewData => http://192.168.10.110:8888/ui/getOverviewData

If I paste the final URLs (right side) in the browser, I hit the service and get the correct response.

Here is the service call, which executes, but it goes to localhost and 404s.

getList(): Observable<applicationModel.ListResponse[]> {
    
    return this.http.get('/ui/getList').map(this.getListResponse);
  }

It makes the service request, but apparently misses the mapping as it just goes to localhost:8100/ui/getList and sends back a 404. :frowning:

Sorry to ask a basic question, but I can’t find much help on this, and I’m not sure how to go about debugging it either. Thanks for your help.

What is your config for proxies?

  "proxies": [{
    "path": "/ui/getList",
    "proxyUrl": "http://192.168.10.110:8888/ui/getList"
  },{
    "path": "/ui/create",
    "proxyUrl": "http://192.168.10.110:8888/ui/create"
  },{
    "path": "/ui/getOverviewData",
    "proxyUrl": "http://192.168.10.110:8888/ui/getOverviewData"
  }]

This should be enough:

"proxies": [{
    "path": "/ui",
    "proxyUrl": "http://192.168.10.110:8888/ui"
  }]

It should get output when you start the ionic serve. You can also test it in the browser directly by calling e.g. localhost:8100//ui/getList

That fixed it!!! Thanks for your help! I’m not sure I understand (okay, I’m sure I don’t) but they all work now.

Actually your configuration should have worked as well, so I also don’t understand. But I learned some time ago that if you can use the same path for different endpoints, just do :wink:

I’m having a lot of trouble with Ionic proxy 404 errors now. I tried this solution and it did not work for me. I wish I could figure out what’s going on.