Meaning of "path" in "proxies" in ionic.config.json

Hi everyone,
I want to add proxies to ionic.config.json for handling CORS during ionic serve, and actually don’t understand the application of “path”. I know that proxies have two member: path and proxyUrl and proxyUrl is the url of webservice, that I try to connect it but what is the meaning of path?
I tried to understand it through “Handling CORS issues in Ionic” article, but the problem is not clear still.
Can anyone explain it for me?
thanks in advanced

A valid configuration looks like this:

 "proxies": [
    {
      "path": "/v1",
      "proxyUrl": "https://api.instagram.com/v1"
    }
  ]

Using the above configuration, you can now make requests to your local server at http://localhost:8100/v1 to have it proxy out requests to https://api.instagram.com/v1

From here: GitHub - ionic-team/ionic-cli: The Ionic command-line interface (Scroll down a bit to “Service proxies”.

Thank you Sujan120 for answer.
If I correctly understand it path must be the name of application on the webserver that I want to connect it but with url on local server at http://localhost:8100, and ionic server redirect my request to webserver. right?
regards

path can be whatever you want it to be. But you will use it in the URL you call instead of the real URL by adding it after localhost:8100 as the path of the URL (get it?).

2 Likes

Thanks a lot Sujan120, Now I think can understand the issue.
Best regards

Hi Sujan12 again,
I have added a proxies tag to ionic.config.json as follows:

	"proxies": [
		{
			"path": "/bvoipdatabase",
			"proxyUrl": "http://192.168.254.201/bvoipdatabase"
		}
	]

and a angular constant

    constant('ApiEndpoint', {
	url: 'http://localhost:8100/bvoipdatabase'
})

then a http get

   $http.get(ApiEndpoint.url + '/bvoip118support.asmx/GetCities')

but in run time the get function return an error such as:

 GET http://localhost:8100/bvoipdatabase/bvoip118support.asmx/GetCities 
 net::ERR_CONNECTION_REFUSED

as you see it seems that proxy does not work
can you please help me, what is wrong for me?

P.S. other hand the url: http://192.168.254.201/bvoipdatabase/bvoip118support.asmx/GetCities in a browser works fine.
Thanks

You have to use the created path

http.get(’/bvoipdatabase’ + ‘/bvoip118support.asmx/GetCities’);

1 Like

thank for reply LoLStats, but the problem stays still and only the error is changed to:
GET http://192.168.252.25:8100/bvoipdatabase/bvoip118support.asmx/GetCities 404 (Not Found)

P.S. 192.168.252.25 is my localhost

Thank a lot LoLStats it’s work. I have restarted ionic server and with a new ionic serve it work
Thank you again
Regrds.

1 Like