[OSRM-talk] OSRM - cannot read JSON responce

sergi_jini s.jishkariani at gmail.com
Mon Dec 28 08:54:14 UTC 2015


Hello Julien,

many thanks for the quick response.

I have added the header to conf (Apache restart), but still getting CORS
error. I believe there is more to modify in config.
Also, I assumed "jsonp" parameter in OSRM was meant to bypass this problem.

I am going to move web server to the same machine as OSRM and see if that
helps.

Br,
Sergi

On Mon, Dec 28, 2015 at 11:10 AM, Julien Coupey <julien at coupey.fr> wrote:

> 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 at openstreetmap.org
>> https://lists.openstreetmap.org/listinfo/osrm-talk
>>
>>
> _______________________________________________
> OSRM-talk mailing list
> OSRM-talk at openstreetmap.org
> https://lists.openstreetmap.org/listinfo/osrm-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/osrm-talk/attachments/20151228/a8405eb4/attachment.html>


More information about the OSRM-talk mailing list