首页 > 解决方案 > Flutter InAppWebView 如何禁用跨域策略?

问题描述

我正在使用 InAppWebView 通过监听 onLoadResource 来制作视频下载应用程序,并抓取用户播放的视频并在 iframe 中播放视频,并且由于跨源策略,我无法获取 iframe 中的 url (.mp4, .m3u8......),我确实将allowUniversalAccessFromFileURLs和allowFileAccessFromFileURLs设置为true,但没有结果我无法获得iframe调用的资源:/,这是我的初始选项:

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,
                  )),
        

如果非常熟悉 inappwebview 或颤振的人会告诉我如何在颤振中禁用跨源策略或如何在不使用代理的情况下收听我的应用程序 http 请求...,我将不胜感激

标签: androidfluttercross-domainsame-origin-policyflutter-inappwebview

解决方案


推荐阅读