cordova-plugin-ionic-webview icon indicating copy to clipboard operation
cordova-plugin-ionic-webview copied to clipboard

feat(ios): add http(s) proxy/scheme

Open NiklasMerz opened this issue 6 years ago • 12 comments

This adds a new URLSchemeHandler which can proxy http(s) requests to external servers. This is useful for some CORS issues and webview bugs that affect the use of cookies in CORS requests via XHR and fetch.

See Webkit bug https://bugs.webkit.org/show_bug.cgi?id=200857

For that reason cookies will be synced between proxied requests on the native layer and the webview.

NiklasMerz avatar Oct 01 '19 17:10 NiklasMerz

If this feature is usefull and gets merged, the documentation needs to be updated probably here: https://beta.ionicframework.com/docs/building/webview#file-protocol ?

NiklasMerz avatar Oct 01 '19 17:10 NiklasMerz

I'm running tests over iOS 13.1.2 and the cookies doesn't reach the server in fetch requests, i.e. <img src="https://mydomain.com/img.jpg" />, but I don't know if there are some kind of configuration or function must need to call before the html is rendered.

fabrodz avatar Oct 03 '19 13:10 fabrodz

You must use the convertFileSrc Javascript function to convert your URLs for using the proxy

NiklasMerz avatar Oct 03 '19 17:10 NiklasMerz

This was done with some suggestions from @jcesarmobile . Do you have any comments on the implementation?

NiklasMerz avatar Oct 04 '19 22:10 NiklasMerz

This is the corresponding documentation that needs to be updated in case this gets merged: https://github.com/ionic-team/ionic-docs/blob/master/src/pages/building/webview.md

NiklasMerz avatar Oct 05 '19 08:10 NiklasMerz

Seems like #376 is the Android version of this change. Adding this feature may mean integrating both PRs.

NiklasMerz avatar Oct 05 '19 09:10 NiklasMerz

I just rebased and resolved conflicts with https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/cbd526d

NiklasMerz avatar Nov 14 '19 12:11 NiklasMerz

Documentation needs to be updated. For basic instrutions see this: https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/475#issuecomment-553871614

NiklasMerz avatar Nov 14 '19 12:11 NiklasMerz

@jcesarmobile Do you see any chances this could be merged? I don't know how relevant this is for the upstream plugin, but I try to mimize forked plugins in our app.

I now know this breaks Anroid currently.

NiklasMerz avatar Nov 28 '19 07:11 NiklasMerz

I tried running this, and it seems to reliably crash my iOS app. Not sure how to provide more info.

alexsasharegan avatar Jan 22 '20 03:01 alexsasharegan

@alexsasharegan You could open you iOS platform in Xcode and run it from there on an iPhone. If the app crashes, you should see an error in the Xcode consoe.

NiklasMerz avatar Jan 22 '20 06:01 NiklasMerz

@NiklasMerz can you please resolve the conflict and thanks ^_^

GroupeBEL avatar Apr 01 '20 08:04 GroupeBEL