<div dir="ltr"><div><div><div><div><div>Hello Julien,<br><br></div>many thanks for the quick response.<br></div><br>I have added the header to conf (Apache restart), but still getting CORS error. I believe there is more to modify in config.<br></div>Also, I assumed "jsonp" parameter in OSRM was meant to bypass this problem.<br><br></div><div>I am going to move web server to the same machine as OSRM and see if that helps.<br></div><div><br></div>Br,<br></div>Sergi<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 28, 2015 at 11:10 AM, Julien Coupey <span dir="ltr"><<a href="mailto:julien@coupey.fr" target="_blank">julien@coupey.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
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:<br>
<br>
Header set Access-Control-Allow-Origin "*"<br>
<br>
See for example <a href="http://enable-cors.org/server_apache.html" rel="noreferrer" target="_blank">http://enable-cors.org/server_apache.html</a><br>
<br>
Hope that helps,<br>
Julien<span class=""><br>
<br>
Le 28/12/2015 08:16, sergi_jini a écrit :<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
Dears,<br>
<br>
Firstly, thanks to all contributors of OSM!<br>
<br>
I have setup OSRM engine on CentOS VM<br>
(<a href="https://github.com/Project-OSRM/osrm-backend/wiki" rel="noreferrer" target="_blank">https://github.com/Project-OSRM/osrm-backend/wiki</a>) and if I query it<br>
via browser directly it is working fine, returning route.json file.<br>
<br>
My problem is that I can't get it working via Javascript. Getting below<br>
error if i query it from my website:<br>
<br>
var resultJSON = {};<br>
<br>
$.ajax({<br>
dataType: "json",<br>
async: false,<br>
cache: true,<br>
url:<br>
'<a href="http://192.168.137.50:5000/viaroute?geometry=true&loc=42.25899995,42.667269338144&loc=42.2695544,42.7017228" rel="noreferrer" target="_blank">http://192.168.137.50:5000/viaroute?geometry=true&loc=42.25899995,42.667269338144&loc=42.2695544,42.7017228</a>'<br>
success: function(data) {<br>
resultJSON = data;<br>
}<br>
});<br>
<br></span>
*Error:*<br>
/"Cross-Origin Request Blocked: The Same Origin Policy disallows reading<span class=""><br>
the remote resource at<br>
<a href="http://192.168.137.50:5000/viaroute?geometry=true&loc=42.25899995,42.667269338144&loc=42.2695544,42.7017228" rel="noreferrer" target="_blank">http://192.168.137.50:5000/viaroute?geometry=true&loc=42.25899995,42.667269338144&loc=42.2695544,42.7017228</a>.<br>
(Reason: CORS header 'Access-Control-Allow-Origin' missing)."<br>
<br></span>
/<br>
Asstated in APi manual, |jsonp={callback name} must be added to request<span class=""><br>
URL, which is not helping either. Tried different variations with jsonp,<br>
cache (which is adding extra _ parameter to the URL), getJson method,<br>
crossdomain : true ...Thinking to read the json on server side via<br></span>
PHP/file_get_contents/ and then send it to front end via json, but can't<span class=""><br>
get it working either. I believe there must be more smooth way as it is<br>
mentioned in the API manuals.<br>
<br>
|<br>
|I would really appreciate if anyone can help me with a working code.<br>
|<br></span>
//<br>
/<br>
<br>
/<br>
Br,<br>
Sergi/<br>
/<br>
<br>
<br>
_______________________________________________<br>
OSRM-talk mailing list<br>
<a href="mailto:OSRM-talk@openstreetmap.org" target="_blank">OSRM-talk@openstreetmap.org</a><br>
<a href="https://lists.openstreetmap.org/listinfo/osrm-talk" rel="noreferrer" target="_blank">https://lists.openstreetmap.org/listinfo/osrm-talk</a><br>
<br>
</blockquote>
<br>
_______________________________________________<br>
OSRM-talk mailing list<br>
<a href="mailto:OSRM-talk@openstreetmap.org" target="_blank">OSRM-talk@openstreetmap.org</a><br>
<a href="https://lists.openstreetmap.org/listinfo/osrm-talk" rel="noreferrer" target="_blank">https://lists.openstreetmap.org/listinfo/osrm-talk</a><br>
</blockquote></div><br></div>