ProxymanApp / Proxyman

Modern. Native. Delightful Web Debugging Proxy for macOS, iOS, and Android ⚡️
https://proxyman.io
5.72k stars 189 forks source link

Requests from WKWebview invisible? #1333

Open fuggly opened 2 years ago

fuggly commented 2 years ago

Proxyman 3.8.0 Mac Monterey 12.5

I apologise if this has been answered somewhere before, but I couldn't really find anything, so I will ask here:

I cannot see any requests from WKWebView. Funny enough, I can see all other requests that we make with our iOS app (outside WKWebview). But those that come from a WKWebView, including the first loading request, but also all other links that are clicked inside, are not visible in Proxyman. We use Atlantis as well and have it running not he debug builds, but regardless of Atlantis included, running or not, WKWebView requests are invisible.

Is there anything we can do to make them visible? Or something we can troubleshoot?

NghiaTranUIT commented 2 years ago

By default, all traffic from WKWebView doesn't go through the HTTP Proxy from your iPhone, so Proxyman could not capture it.

Ref: https://developer.apple.com/forums/thread/110312


So, from what I experience, there is no way to capture traffic from WKWebview on iOS devices.

NghiaTranUIT commented 2 years ago

and here: https://stackoverflow.com/a/55541462/3127477

NghiaTranUIT commented 2 years ago

if you use Proxyman for iOS, I believe that the traffic from WKWebview can be captured because "Proxyman for iOS" uses the VPN, instead of a local proxy server.

fuggly commented 2 years ago

Oh cool thanks, using the VPN I can see the traffic on my device. Cool, thanks!

Carrione commented 1 year ago

Thanks, good to know.

Eddcapone commented 10 months ago

So I need to install proxyman on a MAC book?

NghiaTranUIT commented 10 months ago

@Eddcapone yes, it's. Websocket is a features from the Macbook/Windows version 👍

Eddcapone commented 10 months ago

@NghiaTranUIT Thx, I can confirm that it works on a MAC book. But your wrote Websocket is a feature from Macbook/Windows version, then why does it not work on windows?

NghiaTranUIT commented 10 months ago

@Eddcapone it should work on Windows and Linux too.

  1. Can you describe your setup?
  2. Is it from iOS/Android or your Windows Web Browser app?
Eddcapone commented 10 months ago

@NghiaTranUIT It works, but it does not catch all requests on windows. If I use the mac book, then it catches everything.

NghiaTranUIT commented 10 months ago

@Eddcapone then, it's not a bug from Proxyman. Some Windows apps don't respect the System HTTP Proxy. Their requests go directly to the Internet. So, Proxyman can't capture it.

You might find the Proxy Setting in your Windows app, to see if we can override it.

Eddcapone commented 10 months ago

@NghiaTranUIT It has nothing to do with windows itself, I just host proxyman on a windows machine. I connected from an iphone to proxyman and it did not capture most of the requests.

esteluk commented 3 months ago

On the original point, it's now possible (iOS 17+) to show WKWebView traffic in Proxyman if you manually configure the webview's proxy configuration: https://developer.apple.com/documentation/webkit/wkwebsitedatastore/4264546-proxyconfigurations

NghiaTranUIT commented 3 months ago

@esteluk does it work with fetch/axios on WKWebView ?

NghiaTranUIT commented 3 months ago

Thanks @esteluk . Confirmed that Proxyman can capture traffic from WKWebView

Here is the sample code:

  1. Set HTTP Proxy to WKWebView

    lazy var webView: WKWebView = {
        let webConfiguration = WKWebViewConfiguration()
    
        // ✅ define Proxy Setting to Proxyman
        let httpProxy = ProxyConfiguration(
            httpCONNECTProxy: NWEndpoint.hostPort(
                host: NWEndpoint.Host(
                    "127.0.0.1"
                ),
                port: NWEndpoint.Port(
                    integerLiteral: 9090
                )
            )
        )
    
        // ✅ Tell WKWebView to use the Proxy
        let dataSource = WKWebsiteDataStore.default()
        dataSource.proxyConfigurations = [httpProxy]
        webConfiguration.websiteDataStore = dataSource
    
        // init view
        let webView = WKWebView(
            frame: .zero,
            configuration: webConfiguration
        )
        webView.translatesAutoresizingMaskIntoConstraints = false
        return webView
    }()
  2. Open Proxyman and install the certificate to iOS Simulator (Certificate menu -> Install for iOS -> Simulator). It works with iPhone/iPad physical device too.
  3. Done ✅

Capture network traffic from WKWebView iOS 18