Ajax cross domain on one computer but another port

We have a set of api that we call from the same machine, the address mycompany.com:8080 for the server and mycompany.com for the ajax.html file.

How to avoid cross-domain policies?

Anyway, to do this with some proxy configuration?

please no jsonp!

Thanks!

+4
source share
2 answers

Two or more documents can be considered in the same domain origin if they have - The same host - The same port - The same protocol. In your case, the port is different, so you cannot deliver an ajax request directly. Instead, you need to provide the following answer in response.

  Access-Control-Allow-Origin: mycompany.com 

For more information, check this.

+4
source

You ask if this can be done with proxy server setup and, of course, with one simple solution, just ask for server proxies on the AJAX server. It is usually easy to set up. But the same origin policy means that you cannot do this with a clean client solution.

+1
source

All Articles