0

I am running a virtual machine on my computer (debian 6.0.2.1) that runs an apache+php+mysql server. On my local machine I have a WAMP stack instaled. On both machines I have CodeIgniter deployed and running a RESTful API.

What I am trying to do is to communicate with my virtual machine from the local machine's application. The virtual machine's application accepts post & get methods for an end-point. e.g. http:///thumbs/save/ it should return a message. If I test it in the browser for the get method, it runs fine. The problem is when I try to access it from the other application (local machine deploy) with a jquery post/get I get the following: for chrome as usual: XMLHttpRequest cannot load http:///api/thumbs/save. Origin "http://localhost" is not allowed by Access-Control-Allow-Origin.

and firefox just throws a 200 with status OK but it shows up red and with no response.

A little help would be appreciated. Tell me if you need code examples.

Thanks.

Robert Onodi
  • 120
  • 5

1 Answers1

1

The reason you are seeing that error, Access-Control-Allow-Origin, is to prevent a security issue known as XSS (Cross Site Scripting). Your one domain is localhost, and the other is API.

Take a look at this question/answer for some ways around it. No code examples, so not sure what methods/access types you are using: Access-Control-Allow-Origin error sending a jQuery Post to Google API's

Community
  • 1
  • 1
Mike Mackintosh
  • 13,917
  • 6
  • 60
  • 87
  • not quite what I was looking for. I am aware of the XSS problem. Your answer started me to think that maybe it's not the best solution for local testing, so I decided to make the requests on the server-side with cURL, and now everything works just fine. Thanks for the reminder. – Robert Onodi Jun 09 '12 at 22:05