6

I'm using InAppWebView to make a video downloader app by listening to onLoadResource even and grab the video played by the user and ofc the video inside an iframe and because of cross origin policy i can't get the url inside iframe (.mp4,.m3u8......), i did set allowUniversalAccessFromFileURLs and allowFileAccessFromFileURLs to true but no result i can't get the resources the iframe called :/, this is my initialoptions :

initialOptions: InAppWebViewGroupOptions(
                  android: AndroidInAppWebViewOptions(
                    supportMultipleWindows: true,
                    offscreenPreRaster: true,
                    allowUniversalAccessFromFileURLs: true,
                    allowFileAccessFromFileURLs: true,
                  ),
                  crossPlatform: InAppWebViewOptions(
                    useOnLoadResource: true,
                    debuggingEnabled: true,
                    userAgent:
                        "Mozilla/5.0 (Linux; Android 9; Redmi Note 8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Mobile Safari/537.36",
                    javaScriptEnabled: true,
                    javaScriptCanOpenWindowsAutomatically: true,
                  )),
        

if anyone very familiar with inappwebview or flutter would tell me how to disable the cross origin policy in flutter or how to listen to my app http requests without using a proxy ... , i'll be grateful

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197

1 Answers1

0

There are many reasons why the url does not load, in my case I got this Uncaught (inpromise) TypeError: Failed to fetch, due to that I had to intercept the requests, and it came out that webview does not validate the SSL certificate

initialOptions: InAppWebViewGroupOptions(
    android: AndroidInAppWebViewOptions(
    useShouldInterceptRequest: true, 
    ),
)

androidShouldInterceptRequest: 
(controller, request) async {
    print("request $request");
}

to ignore ssl certificate errors

onReceivedServerTrustAuthRequest: (controller, challenge) async {
    print("challenge $challenge");
    return ServerTrustAuthResponse(action: 
ServerTrustAuthResponseAction.PROCEED);
}