我正在尝试使用weinre进行调试,并在Chrome中设置了一个简单的测试,以确保一切正常.但是,在开发人员工具中我收到错误:
"The page at 'https://myhost/...' was loaded over HTTPS, but ran insecure content from 'http://localhost:8080/target/target-script-min.js': this content should also be loaded over HTTPS.
我已经看到了关于调试"Cordova"或"Phonegap"的其他一些答案.我没有使用这些东西中的任何一个,建议的答案似乎不适用于此.我试图只调试简单的HTML/Javascript.
我在weinre网页上没有看到启用https支持的任何提及(它明确提到它不使用https),并且我没有很多控制浏览器端(这需要在各种工作上工作)在我看来臭名昭着的android浏览器,对本地调试完全不友好,这实际上是我尝试使用weinre调试的原因),所以我不知道如何继续.由于页面传递敏感信息,因此不使用https是不可能的; 使用weinre over http是可以接受的,因为我通过ssh隧道连接.
更新:我还尝试使用boomarklet方法:我将书签网址添加到Chrome Mobile,但是当我尝试导航到书签时,它似乎卸载原始页面:我可以看到连接,但是当我看到资源,我看到的只是书签.但是,如果我尝试通过键入书签的名称来运行书签,直到标记的javascript代码出现在自动完成中,它将保留在当前页面上,但客户端页面中不会显示任何目标.我认为这是出于同样的原因,因为我看到书签正在引用http://localhost:2000
.
为了获得浏览器限制,我们可以使用反向代理从https而不是http来提供页面.这有点像一个暴力解决方案,但在我的/etc/httpd.conf
文件末尾添加以下行足以代理我们从服务器请求的所有页面:在我的情况下,这些都不会与现有文件或目录冲突.
ProxyPass /target/ http://localhost:8080/target/ ProxyPassReverse /target/ http://localhost:8080/target/ ProxyPass /client/ http://localhost:8080/client/ ProxyPassReverse /client/ http://localhost:8080/client/ ProxyPass /weinre/ http://localhost:8080/weinre/ ProxyPassReverse /weinre/ http://localhost:8080/weinre/ ProxyPass /interfaces/ http://localhost:8080/interfaces/ ProxyPassReverse /interfaces/ http://localhost:8080/interfaces/ ProxyPass /modjewel.js http://localhost:8080/modjewel.js ProxyPass /images/ http://localhost:8080/images/ ProxyPassReverse /images/ http://localhost:8080/images/ ProxyPass /ws/ http://localhost:8080/ws/ ProxyPassReverse /ws/ http://localhost:8080/ws/
还有必要定义window.WeinreServerURL,因为Weinre正在使用regex http:/
来尝试获取服务器的URL.这将失败,因为服务器是https而不是http.在我的例子中,我将以下形式的声明添加到bookmarklet作为函数中的第一个语句:
window.WeinreServerURL="https://server:port/
有了这个,我就可以指向我的浏览器调https://server:port/client/#anonymous
出调试页面,并在调试页面下运行bookmarklet.