How to solve cross-domain error in Oracle Mapviewer hosted on Glassfish

201 views Asked by At

I have made an HTML5 application (hosted on localhost) that interacts with a remote MapViewer server (hosted on a remote server using Glassfish 4) using it's JavaScript library.

<script src='http://192.168.1.99:8088/mapviewer/jslib/v2/oraclemapsv2.js'></script>

The JavaScript library is making calls to it's own domain http://192.168.1.99:8088to load CSS files, images and access web services, but returning cross domain error since I am actually hosting my HTML5 app on my localhost.

XMLHttpRequest cannot load http://192.168.1.99:8088/mapviewer/omserver?xml_request=%3Cnon_map_reques…rce%3D%22tcg_seff%22+style%3D%22T.ZIPCODE%22%2F%3E%3C%2Fnon_map_request%3E. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.

Any idea how to solve this?

1

There are 1 answers

0
Stephen R. Smith On

What you need to do is enable Cross Origin Resource Sharing on the MapViewer server.

You can find more information about this here: http://www.html5rocks.com/en/tutorials/cors/