Whitelisting http requests from QWebFrame::evaluateJavaScript



  • Hi folks:

    I want to know if there is a way to whitelist http requests issued by 3rd party JS file which is executed by QWebFrame::evaluateJavaScript.

    Our application need to execute some JS function from an external JS file. We need to prevent that JS getting data other than a whitelist domain. e.g.
    frame()->evaluateJavaScript("getYahooData()")

    We want to make sure that getYahooData() will only make network requests to www.yahooapi.com domain only.

    Is there any way to get that? Thanks a lot!


  • Moderators

    Hi@Wei-Seattle
    In the old QWebView there was a way to set custom a QNetworkAccessManager where in one can re-implement some of its methods to intercept the requests.
    If you are using the old version check the following post:
    https://forum.qt.io/topic/51631/how-can-we-restrict-qwebview-not-to-download-some-js-and-css-files/2

    But if are using a latest i.e Qt WebEngine then you will need to update to Qt 5.6 where they have added new API's to do so. As per this doc.

    We’ve also added a new Qt WebEngineCore module for new low-level APIs. This includes features such as support for custom URL schemes, intercepting and blocking network requests and for tracking and blocking cookies.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.