互联网不能从波纹仿真器访问 [英] Internet not accessible from ripple emulator

查看:137
本文介绍了互联网不能从波纹仿真器访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个VS Cordova项目,需要从网络服务下载一些数据,但Ripple在Chrome中运行,Chrome认为该请求为跨域并阻止它。将ripple proxy选项设置为disabled / local / remote不起作用。我可以使用--web-security-disabled命令行选项启动另一个Chrome实例,将其指向同一网址 http:// localhost :4409 / ...和应用程序工作正常在那第二个Chrome。现在我需要的是找到一种方法来传递--web-security-disabled到Chrome当我在Visual Studio中按F5启动它。它可能在某个配置文件中,只需要找到它...

I created a VS Cordova project, and need to download some data from a web service, but Ripple runs inside Chrome, and Chrome considers that request "cross-domain" and blocks it. Setting ripple proxy option to disabled/local/remote has no effect. I can start another instance of Chrome with --web-security-disabled command line option, point it to the same URL http://localhost:4409/... and application works fine in that second Chrome. Now all I need is to find a way to pass --web-security-disabled to Chrome when I start it by pressing F5 in Visual Studio. It's probably somewhere in some config file, just need to find it ...

推荐答案

很难知道,


  1. 您的代码绕过了Ripple中的CORS代理
  1. Your code is bypassing the CORS proxy in Ripple
  2. Proxying through Ripple is resulting in the web server denying the request.
  3. You have the Ripple extension installed in Chrome. In effect you can end up with two Ripples running which can cause a number of unexpected behaviors.

要知道发生了什么,请确保CORS代理设置为本地并检查网络选项卡。到www.bing.com的XHR调用看起来像这样:

To know which is happening, be sure the CORS proxy is set to "local" and check the network tab. An XHR call to www.bing.com would look something like this:

http:// localhost:4400 / ripple / xhr_proxy?tinyhippos_apikey = ABC& tinyhippos_rurl = http%3A // www.bing.com < a>

http://localhost:4400/ripple/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=http%3A//www.bing.com

尝试从index.html页面执行此操作,看看是否成功通过代理。

Try just doing this from your index.html page and see if it succesfully goes through the proxy.

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.open("GET", "http://www.bing.com", true);
    xmlhttp.send();

如果你需要进一步调试,或者你想在Visual Studio之外使用Ripple, Ripple npm包,并在Visual Studio外使用它。在调试配置中为Android构建,然后转到bld / Debug文件夹,并从命令提示符处执行以下命令:

If you need to further debug or you want to use Ripple outside of Visual Studio, you can actually install the Ripple npm package and use it outside of Visual Studio. Build for Android in the debug config, then go to the bld/Debug folder and execute the following from the command prompt:

    npm install -g ripple-emulator
    ripple emulate android --port 12345

出现。如果不是您的默认值,请将其粘贴到Chrome中,然后重试。

A browser Window will appear. Paste that into Chrome if its not your default and retry. You can then see what is going through the proxy in the command prompt.

您也可以使用相同的方法使用Chrome开发工具调试您的应用程式,并附上--web -security-disabled。

You can also use this same method to debug your app using the Chrome Dev Tools with --web-security-disabled.

这篇关于互联网不能从波纹仿真器访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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