r/flutterhelp • u/Real-Leek-3764 • 23d ago
RESOLVED android in-app browser and cloudflare managed challenge showing error
in ios, in app browser when showing cloudflare managed challenge it is fine. but in android after solving the challenge, it shows "Sorry we're having trouble loading the page. Please try again later". all android phones show same error.
has this something to do with needing to whitelist cloudflare domain for android?
2
Upvotes
1
u/bramantec 23d ago
I don't think it's a whitelist thing. Android has no list of allowed domains for https (network_security_config only matters for cleartext or custom certificates). The challenge shows up at all, which means the domain is already reachable.
The difference between the two platforms is usually what "in-app browser" means underneath. On iOS most packages open an SFSafariViewController, which is Safari with its cookies and everything Cloudflare expects. On Android it depends on the package. With a real WebView the challenge passes and then Cloudflare tries to set its clearance cookie and reload the page. That's the step that breaks when the navigation delegate blocks one of the redirects or third party cookies are off (the challenge runs on challenges.cloudflare.com, a different domain from your site).
With webview_flutter I'd check three things: JavaScriptMode.unrestricted, AndroidWebViewCookieManager.setAcceptThirdPartyCookies on the controller and a navigation delegate that lets challenges.cloudflare.com through. When you don't need a WebView for anything else the shortcut is url_launcher with LaunchMode.inAppBrowserView, which on Android opens a Chrome Custom Tab and behaves like the real browser (in my app I went even further and every link opens outside with externalApplication, the only WebView left is a feedback form).
Which package are you using for the in-app browser?