Internet not accessible from ripple emulator

前端 未结 1 922
南笙
南笙 2021-01-28 10:16

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 i

相关标签:
1条回答
  • 2021-01-28 10:33

    It is difficult to know without looking at the exact code, but it is likely that one of a few of things is happening:

    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.

    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

    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();
    

    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
    

    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.

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

    0 讨论(0)
提交回复
热议问题