0

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 ...

Boris Geller
  • 39
  • 1
  • 3
  • Setting the Cross Domain Proxy option to Disabled works just fine for me. I haven't changed any other settings. Have you tried debugging with the Chrome Developer tools. i.e. click on your browser and press F12. Check out the network tab and see what happens when you try to communicate with a web service. – Andrew Feb 26 '15 at 09:42
  • Thanks for your reply. In the network tab I see the request going out and returning with status 200 OK. However the response body is empty and I see an error in the console tab " XMLHttpRequest cannot load http://....... No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access." Same for all ripple proxy options disabled/local/remote. If I start Chrome with --disable-web-security flag, response headers look the same, but response body is now not empty and everything works OK. But how to pass that flag from VS to Chrome? – Boris Geller Feb 26 '15 at 12:08

1 Answers1

1

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.

Chuck Lantz
  • 1,440
  • 1
  • 8
  • 10
  • 1
    Probably something is non-standard with my http request: it is sent from within an iframe with sandbox attribute set. I am currently able to sort of work around it with the second instance of Chrome pointed to the http server that VisualStudio creates http://localhost:4409/... – Boris Geller Feb 28 '15 at 21:14