Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-61921

No way of setting default baseUrl when using load() method in QWebEnginePage

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • None
    • 5.9.1
    • WebEngine
    • None
    • MacOs

    Description

      Missing API.

      When using something like:

       

      webView->load("/some/absolute/path/to/index.html");
      

      I get 404 errors for assets loaded using relative-to-/ urls, like:

       

      <img src="/images/something.jpg"/>
      

      This is because, the actual document.location is actually something like file:///some/absolute/path/to/index.html and its trying to fetch image from file:///images/something.jpg instead of file:///some/absolute/path/to/images/something.jpg resulting in an 404 HTTP "not found" error.

      Just like when using setHtml() and setContent(), you should be able of setting baseUrl to handle this kind of behaviour, specially for when you cannot alter assets paths. This would somehow emulate using a webserver.

       

      I tried injecting a <base> tag after DOM render, but it's not working as expected.

      Another workaround would be to fetch the index.html file contents, and use setHtml() with the HTML string and passing preferred baseUrl.

      Any advice or comments??

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt_webengine_team Qt WebEngine Team
            whallz Andres Bolocco
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes