You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Of course the src is a placeholder, but the important part is that it uses "//" to qualify the protocol instead of saying "http://" or "https://".
This is meant to mount some JavaScript and render things into the page, but it calls third party APIs using the same "//" protocol. I can modify the script tag to contain "https://cdn.thirdpartysite.com", but that does not fix the issue where subsequent requests fail.
From troubleshooting, I've found that this behavior exactly matches what happens when you open an html file in your browser, and it uses the "file://" protocol.
From my research on this, I can't find a way to get around this other than hosting the HTML on a server instead of inlining it, however that will make things more complicated.
Does anybody know of any way to make the webview treat inlined HTML as using the http or https protocol instead of "file:"? I understand this may not be possible or reasonable since it is, in fact, not using the http protocol, but I just thought I'd give it a shot and ask the question.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I am trying to use a WebView to run some HTML code and embed it into my app. The HTML code is supplied by a third party, and it looks like this:
Of course the src is a placeholder, but the important part is that it uses "//" to qualify the protocol instead of saying "http://" or "https://".
This is meant to mount some JavaScript and render things into the page, but it calls third party APIs using the same "//" protocol. I can modify the script tag to contain "https://cdn.thirdpartysite.com", but that does not fix the issue where subsequent requests fail.
From troubleshooting, I've found that this behavior exactly matches what happens when you open an html file in your browser, and it uses the "file://" protocol.
From my research on this, I can't find a way to get around this other than hosting the HTML on a server instead of inlining it, however that will make things more complicated.
Does anybody know of any way to make the webview treat inlined HTML as using the http or https protocol instead of "file:"? I understand this may not be possible or reasonable since it is, in fact, not using the http protocol, but I just thought I'd give it a shot and ask the question.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions