使用 webview_flutter 包,我可以加载我的网站并将会话 cookie 添加到初始 URL。
_controller.future.then((controller) {
_webViewController = controller;
Map<String, String> header = {'Cookie': 'ci_session=${widget.sessionId}'};
_webViewController.loadUrl('https://xxxx.com', headers: header);
});
Run Code Online (Sandbox Code Playgroud)
为了保持会话进行,我需要为所有请求添加相同的标头,而不仅仅是初始请求。有没有办法拦截所有请求并通过向它们添加标头来修改它们?
我发现的最接近的事情是navigationDelegate 但它只返回一个NavigationDecision在我的情况下没有用的。