-1

I'm running a server application in Tomcat 7 on port 8081 of my localhost and a client js-application in wamp (think thats port 80). When I try to run it (in chrome), i'm getting this error in my console:

XMLHttpRequest cannot load http://localhost:8081/blabla/bla/config Origin http://localhost is not allowed by Access-Control-Allow-Origin

Does anyone have an idea how to fix it? The code runs fine if I check with unit test and debugging. The error is thrown when the response reaches the client

If I just go to http://localhost:8081/blabla/bla/config in my browser, I get the right response in JSON

dumazy
  • 13,857
  • 12
  • 66
  • 113
  • I would recommend looking up access control allow origin. Basically you are only allowed make xhr requests to the same origin as the parent page, including the port. – Frances McMullin Mar 18 '13 at 11:58

1 Answers1

1

I think you neeed take a look at CORS at W3C:http://www.w3.org/TR/access-control/

Your site (the origin) need to aswer with a access-control-allow-origin response header to be allowed. You need to add to your server.

http://www.w3.org/TR/access-control/#access-control-allow-origin-response-header

This question can help too: Access-Control-Allow-Origin in tomcat

Community
  • 1
  • 1
Vitor Canova
  • 3,918
  • 5
  • 31
  • 55