I need to Intercept all HTTP requests/responses (GET/POST) in a website that loads on WkWebView in the Swift app. I tried to work with this plugin [https://github.com/tommy19970714/WebKitURLProtocol]. I was able to intercept with GET request, But it cannot work with POST requests because the POST request body is always missing when I intercept it on the swift.
You can do this in the navigation delegate method decidePolicy :
optional func webView(
_ webView: WKWebView,
decidePolicyFor navigationAction: WKNavigationAction,
decisionHandler: @escaping (WKNavigationActionPolicy) -> Void
)
the navigationAction parameter contains the URLRequest which contains the httpBody of the POST request.