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

WIP: [LocalProxy - CORS] Proxy requests using the local server

Open edunad opened this issue 5 years ago • 6 comments

Android only, improvements are welcome!

So far I've seen the ability to proxy requests using a known ip, this was not suitable for me. Now you can perform http://localhost/_local_proxy_/<link_here> and it will proxy the request to <link_here>, as well as injecting some CORS headers.

Ideally you would want : localproxy:// instead, but had problems implementing a custom schema

Example :

<audio id='TEST' src='http://localhost/_local_proxy_/https://raw.githubusercontent.com/tgstation/tgstation/master/sound/magic/magic_missile.ogg'></audio>

Result:

Sorry if this is already possible, could not find it :(

Related to: https://github.com/ionic-team/cordova-plugin-ionic-webview/pull/230 (iOS only), https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/227 and https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/47

edunad avatar Jun 12 '19 11:06 edunad

Just found few issues, will open again when fixed :)

edunad avatar Jun 12 '19 13:06 edunad

Trying to fix the range issue, it seems if you skip the stream ahead, it will create a loop :P

edunad avatar Jun 13 '19 08:06 edunad

Great job @edunad ! I am trying to integrate your PR in my version for Android. Did you try using the proxy for POST requests? I did not find out how to get this working, yet.

NiklasMerz avatar Nov 28 '19 14:11 NiklasMerz

@NiklasMerz Thanks! Sadly my java android knowledge is kinda limited, i expected the ionic team to give a hand into solving the issues i've encountered (specifically with PARTIAL CONTENT). I haven't tried POST but i suspect it would work fine, since it's just appending the CORS into the response headers

edunad avatar Nov 28 '19 15:11 edunad

The problem with POST is that it does not pass the body through the proxy. I need a way to do that. The WebResourceRequest class is kind of limited. I will probably figure that out. Thank you for starting this.

NiklasMerz avatar Nov 28 '19 15:11 NiklasMerz

I can confirm that range requests are not supported correctly + the curent implementation breaks video playback, please either drop support, and support it correctly.

yelhouti avatar Dec 19 '20 13:12 yelhouti