When trying to display a map with leaflet from my https protected website, I had the following problems:
* remote css and js leaflet library files could not be served from https and thus were blocked by my browser.
* when that was fixed, the tiles from OSM being called from http and not https, they were blocked by my browser.

I fixed this by switching to cloudflare's CDN and by changing the default tile source to https and that worked for me. I don't have an http environment at hand to test it so I'll share my patch and somebody can give it a try or make it better!

Comments

juliencarnot created an issue. See original summary.

juliencarnot’s picture

StatusFileSize
new1.66 KB
steven jones’s picture

Status: Active » Needs review

Marking as needs review as we have a patch.

steven jones’s picture

Status: Needs review » Reviewed & tested by the community

This works really nicely on both http and https. I guess maybe the module should provide an option for loading the library locally rather than using a CDN? (that would be a follow up issue)

acbramley’s picture

+1 this works well, definitely agree with #4 that the module should provide a local option for serving instead of using a CDN.

juliencarnot’s picture

Thanks for testing!

Feel free to open another issue about "providing an option to serve LeafletJS locally instead of from a CDN" and to reference it here so that this patch can move forward, I still haven't benchmarked both solutions to find the best performance/reliability/privacy compromise, so I don't have a strong case for this feature...

If it is a specific requirement for a project, one could always edit the leaflet.libraries.yml file to replace remote calls with a local path as a workaround.

  • pvhee committed 2f0bd55 on 8.x-1.x
    Issue #2753703 by juliencarnot: Allow leaflet to be used on a https /...
pvhee’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the patch, I've committed parts of #2 and note that the CDN support has been fixed via #2808097: Use unpkg CDN for Leaflet.

For local Leaflet library support please open a new issue!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.