3

I´am developing a few Apache Cordova Apps in Visual Studio 2015 and test it with the Ripple Emulator.

Since a few days, my connections to the server doesn´t work anymore.

I get the following error.

XMLHttpRequest cannot load http://xxxxx. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4400' is therefore not allowed access. The response had HTTP status code 401.

Based on other questions in stackoverflow, I tried to change the Cross Domain Proxy to Remote or to Local without success.

I also added the <access origin="*" /> to my config.xml

<?xml version="1.0" encoding="utf-8"?>
<widget xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:vs="http://schemas.microsoft.com/appx/2014/htmlapps" id="io.cordova.app" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" defaultlocale="de-AT">
  <content src="index.html" />
  <access origin="*" />
....

If I started a new chrome-window with the parameter --disable-web-security it works. (But in the new chrome-window, I can´t debug with visual studio.)

alexander-fire
  • 1,082
  • 4
  • 27
  • 52

2 Answers2

0

There is a Chrome extension that can fix this. Please give this a try and let me know if it helps:

https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi

We will see if there's something we can add to our tools to make this easier in the future.

(Disclosure: I work on the Tools for Apache Cordova in Visual Studio).

Michael Braude
  • 6,913
  • 1
  • 22
  • 20
  • Hey... Thank you for your answer. I´ve already installed this extension but it doesn´t work since a few chrome versions. (Now I worked with the workaround, described on the answer below.) – alexander-fire Feb 08 '16 at 06:01
0

Sometimes the extension mentioned above doesn't work, depending on your version of Chrome. So, people have found success using this workaround here on stack: Visual Studio, Ripple Emulator and CORS/Cross Domain Ajax

Community
  • 1
  • 1
Linda Z
  • 312
  • 1
  • 5
  • Thank you for your answer. This is exactly the workaround which I´m using since the problem occoured the first time. I hope it would be a better an more comfortable solution soon. – alexander-fire Feb 08 '16 at 06:02