Google Maps CORS issue after upgrade to WKWebview


#1

I’m working with iPhone 7 plus and iOS 11, and I’ve just updated to WKWebview, and now I’m having issues with my Google Maps ionic native plugin. This is the error I’m getting when testing on my device:

ClientParametersRequest failed, 7 attempts remaining (0 vs 10). Error Domain=com.google.HTTPStatus Code=400 "(null)" UserInfo={data=<3c44d ...........>}

I’m not 100% sure, but I think it’s some issue with CORS, which is now required with WKWebview.

I’ve read in a few places that you can bypass it via a Proxy, by adding the following in your ionic.config.json files:

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

But it’s not working, and I’m not sure if I got the path and proxyURL correct.

Any advice on this will be greatly appreciated!


#2

I just recently updated to WKWebview as well and ran into CORS issues. I was able to implement the native plugin HTTP and got it working.


#3

Using @ionic-native/http made it work for me on mobile, and using the proxy made it work no browser.

For anyone reading this, my app was breaking when using spaces in the query for the autocomplete api, using encoreURI(url) fixed it.