Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
None
-
5.9.1
-
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??