Cordova在应用程序浏览器中的应用程序传输安全性 [英] Cordova In app browser App Transport Security

查看:109
本文介绍了Cordova在应用程序浏览器中的应用程序传输安全性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从本地服务器(使用httpd插件)在In App Browser中加载内容.网页来自https,而本地服务器当然加载了http.

I am trying to load content in an In App Browser from my local server ( using httpd plugin ). the web page is coming from a https, while the local server is loading of course a http.

我正在Iphone x IOS 12上进行测试.使用Adobe Build

I am testing on an Iphone x IOS 12. Using adobe Build

尝试:

<access origin='*' allows-arbitrary-loads-in-media='true' allows-arbitrary-loads-in-web-content='true' allows-local-networking='true' />

<edit-config target="NSAllowsArbitraryLoads" file="*-Info.plist" mode="merge">

<true />

</edit-config>

<plugin name="cordova-plugin-transport-security" source="npm" />

错误:

[blocked] The page at https://somewebpage was not allowed to run insecure content from http://127.0.0.1:8080/javascripts/somejsfile.js.

这些都不起作用.有人有建议吗?

none of these worked. anyone have a suggestion?

推荐答案

不更改浏览器安全设置的另一种Android解决方案是使用"https://cdvfile/assets/www/cordova.js"代替"cdvfile://localhost/assets/www/cordova.js",并添加以下行到FileUtils.java中的remapUri方法(在cordova文件插件中):

Another solution for android that doesn't change the security settings of the browser, is to use "https://cdvfile/assets/www/cordova.js" instead of "cdvfile://localhost/assets/www/cordova.js", and add the following line to the remapUri method in FileUtils.java (in the cordova file plugin):

uri = Uri.parse(uri.toString().replace("https://cdvfile/", "cdvfile://localhost/"));

这将照常加载文件,并且不会导致网络视图阻止请求.

This will load the file as usual and not cause the webview to block the request.

请参见PR https://github.com/apache/cordova-plugin -file/pull/322

这篇关于Cordova在应用程序浏览器中的应用程序传输安全性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆