cordova-plugin-ionic-webview
cordova-plugin-ionic-webview copied to clipboard
WIP: [LocalProxy - CORS] Proxy requests using the local server
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
Just found few issues, will open again when fixed :)
Trying to fix the range issue, it seems if you skip the stream ahead, it will create a loop :P
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 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
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.
I can confirm that range requests are not supported correctly + the curent implementation breaks video playback, please either drop support, and support it correctly.