Unwanted trailing slash on Ionic CLI proxy


#1

I’m dealing with CORS issues when developing while trying to reach an API endpoint. I’ve set-up a proxy via the ionic.properties so the CLI can handle the requests.

The main problem here is, the API I’m trying to access cannot respond correctly to a trailing slash that’s being added by the CLI.

While my proxy config says “http://domain.com/api.asmx/method”, the request is being done as “http://domain.com/api.asmx/method/” (note the trailing slash) and the endpoint responds as “method/” not found (note again the trailing slash).

Any thoughts? This looks like a bug to me.


#2

Anything about this, Mike? @mhartington


#3

Same issue here is well. Testing with Ionic2 CLI, and getting the trailing slash when added to ionic.config.js in the proxy array. Trying to fetch a resource from Google Places API over http.


#4

Does anyone have a workaround for this ?


#5

I use a CORS plugin in chrome


#6

Hello, I’m dealing with the same issue. The chrome plugin is more like a workaround. Did someone find a solution ?


#7

My workaround was to put only the base path as the proxy leaving the rest of the base path to the actual request:

"proxies": [
    {
      "path": "/maps",
      "proxyUrl": "https://maps.googleapis.com/maps"
    }
  ]  

then in the app this.http.get('http://localhost:8100/maps/rest/of/base/path');