perliedman / leaflet-routing-machine

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

leaflet-routing-machine.js:88 Mixed Content: The page at '' was loaded over HTTPS #586

Closed sunstarwar closed 2 years ago

sunstarwar commented 4 years ago

Hi friends,

i am working in a leaflet routing map, when i was working in a local machine it doesn't say error but when i move the code to server throws an error like "leaflet-routing-machine.js:88 Mixed Content: The page at 'https://moesctest.artha.com/Employee/Students_OnRoute_OSM.aspx' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://router.project-osrm.org/route/v1/driving/-74.1170343,40.4456482;-74.1195227,40.4440501;-74.1189951,40.4431026;-74.1234684,40.4424305;-74.126634,40.4413222;-74.1290197,40.4491485;-74.1305336,40.4500597;-74.1352131,40.4517255;-74.1372316,40.4491365;-74.1374725,40.4490829;-74.129298,40.4371859?overview=false&alternatives=true&steps=true&hints=;;;;;;;;;;'. This request has been blocked; the content must be served over HTTPS."

I dont know much knowledge in leaflet routing machine, so i need help to make this work in server any help would be appreciated..

thanks in advance...

ThomasG77 commented 4 years ago

As mentioned in the README.md from this plugin project, the https certificate from the https://router.project-osrm.org URL expired. You can't really avoid to use your own server for OSRM (see below screenshot from the mentioned README.md). Imagining your server could be hosted without a certificate, (so without https only http), you would be able to call OSRM demo url without http but you would be stuck by another problem: you absolutely need https for using geolocation e.g https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API

Sélection_193

rebos commented 3 years ago

As of today, the OSRM's demo server seems to be back again and is presenting a valid certificate for HTTPS verified by Let's Encrypt:

grafik

Probing the routing service via HTTP GET with an URL copied from the API documentation seems to produce a valid response.

But nevertheless currently the demo page for leaflet-routing-machine still shows an error message:

grafik

mguignes commented 2 years ago

Hello, It is said that we should be using our own server. But if we are not able to use a valid certificate, how should we proceed ??? Because using the demo server, we will always be limited to a certain number of requests per second...

curtisy1 commented 2 years ago

But if we are not able to use a valid certificate, how should we proceed ???

You have a few options.

  1. If you want to self-host an OSM server, you can get a free certificate via Let's Encrypt
  2. Use a different routing provider such as Mapbox or a different OSM router
  3. Use Http instead of Https (although I would generally advise against this)

Because using the demo server, we will always be limited to a certain number of requests per second...

The demo server is generally feasible if you want to prototype some application. It's not suitable for production use since it would probably drastically increase server load (and cost) for the OpenStreetMap folks and as such throttle all the other people wanting to use the demo server.

That being said, the demo server is working fine now as can be seen in the docs. They use https://routing.openstreetmap.de/routed-car/route/v1 for routing now by default

curtisy1 commented 2 years ago

Closing as this seems to be resolved. If the issue persists, feel free to open another one or ask me to reopen this one