perliedman / leaflet-routing-machine

Control for routing in Leaflet
https://www.liedman.net/leaflet-routing-machine/
Other
1.08k stars 350 forks source link

Use http instead of https - not have "s" #574

Closed duongvanle closed 4 years ago

duongvanle commented 4 years ago

I see that this lib send request to get direction data as https, like this: https://router.project-osrm.org/route/v1/driving/105.8341598,21.0277644;105.9341598,21.0277644?overview=false&alternatives=true&steps=true&hints=; The response is error. If i replace https to http, it works. Tried on the browser directly Also, according to its document http://project-osrm.org/docs/v5.22.0/api/#requests, it use http, not https. Please help me this issue. Thanks

Mehditerranee commented 4 years ago

@duongvanle Indeed, the HTTPS certificate has expired and won't be renewed. If you're pointing your self-hosted frontend at OSRM, you'll need to use http://router.project-osrm.org/ (not https), or point it at your own OSRM server. (cf. https://github.com/Project-OSRM/osrm-frontend/issues/320)

I am also looking for a solution to point to http link and not https.

@perliedman an idea?

perliedman commented 4 years ago

Hi guys, as mentioned above, the SSL cert for OSRM's demo server has expired, and at this point no-one is maintaining it as far as I have understood the situation.

The demo server has always been, well, a demo server, and not intended for production use. So, the solution is to either set up OSRM on your own servers (quite easy for small geographic areas, demanding for global coverage), or use a paid service. Leafler Routing Machine has built-in support for Mapbox's directions API, so that easy probably the easiest to get going, but there are many options, see the docs.

Mehditerranee commented 4 years ago

@perliedman Indeed, it is a demo server, but the expiration of the SSL cert should not prevent its use for testing in a QA environment.

perliedman commented 4 years ago

I think you can expect the demo server to stop working completely, as I understand it Mapbox has no interest in maintaining it any more, and no one else has indicated they want to take over maintenance.

Having said that, I think I could make that change if it helps.

Mehditerranee commented 4 years ago

@perliedman Yes, it would be very appreciable to make that change!

I tried to use the serviceUrl parameter with the link "http://router.project-osrm.org/route/v1/" (without 's' for http) to see if that could do the trick, but it changes absolutely nothing. I get the same error.

Capture d’écran 2020-04-07 à 17 32 59
Mehditerranee commented 4 years ago

@duongvanle Ok, I found the trick.

For those who are searching a solution for this :

The link used for the demo server by leaflet is materializing as below: serviceUrl: 'https://router.project-osrm.org/route/v1'

So, we have to overwrite this line by adding this one (whithout 's' for http) to the router: serviceUrl: 'https://router.project-osrm.org/route/v1'

like this :

router: new L.Routing.osrmv1({
    serviceUrl: 'http://router.project-osrm.org/route/v1' 
}),