Hi,
This seems to be related to your web server policy (and nothing to do
with OSRM). I had the same situation a while back and solved it by
adding the following to the relevant apache .conf file:
Header set Access-Control-Allow-Origin "*"
See for example http://enable-cors.org/server_apache.html
Hope that helps,
Julien
Le 28/12/2015 08:16, sergi_jini a écrit :
Dears,
Firstly, thanks to all contributors of OSM!
I have setup OSRM engine on CentOS VM
(https://github.com/Project-OSRM/osrm-backend/wiki) and if I query it
via browser directly it is working fine, returning route.json file.
My problem is that I can't get it working via Javascript. Getting below
error if i query it from my website:
var resultJSON = {};
$.ajax({
dataType: "json",
async: false,
cache: true,
url:
'http://192.168.137.50:5000/viaroute?geometry=true&loc=42.25899995,42.667269338144&loc=42.2695544,42.7017228'
success: function(data) {
resultJSON = data;
}
});
*Error:*
/"Cross-Origin Request Blocked: The Same Origin Policy disallows reading
the remote resource at
http://192.168.137.50:5000/viaroute?geometry=true&loc=42.25899995,42.667269338144&loc=42.2695544,42.7017228.
(Reason: CORS header 'Access-Control-Allow-Origin' missing)."
/
Asstated in APi manual, |jsonp={callback name} must be added to request
URL, which is not helping either. Tried different variations with jsonp,
cache (which is adding extra _ parameter to the URL), getJson method,
crossdomain : true ...Thinking to read the json on server side via
PHP/file_get_contents/ and then send it to front end via json, but can't
get it working either. I believe there must be more smooth way as it is
mentioned in the API manuals.
|
|I would really appreciate if anyone can help me with a working code.
|
//
/
/
Br,
Sergi/
/
_______________________________________________
OSRM-talk mailing list
OSRM-talk@openstreetmap.org
https://lists.openstreetmap.org/listinfo/osrm-talk
_______________________________________________
OSRM-talk mailing list
OSRM-talk@openstreetmap.org
https://lists.openstreetmap.org/listinfo/osrm-talk