Using OSM tiles in a local file

Is it possible to use OSM tiles in a Leaflet-style map hosted in a local file? Since local files do not have Referer headers, tile requests are getting blocked with error code 403r due to lack of referer.

This is different from Error 403 when using local files - referer missing - can I use User Agent and what should it contain, which was solved by setting a custom User-Agent header. Here, I’m just using a plain HTML file opened in a standard browser.

Causes issue Default OSM tiles blocked due to lack of `Referer` · Issue #37 · clarisma/libgeodesk · GitHub

See Error 403 when using local files - referer missing - can I use User Agent and what should it contain - #46 by Spiekerooger for a solution

1 Like

That solution adds a X-Requested-With header when opening the leaflet map in a local file:// html. (As the User-Agent cannot be changed and as no referrer is send by the local file)

Again, see post#46 in that thread (the last post & the one I linked to above)

1 Like

Great, thanks, I’ll give this a try!

1 Like

In the Leaflet-plugin’s description GitHub - jaq316/leaflet-header: Custom headers on Leaflet TileLayer · GitHub it says, the plugin is for “Leaflet TileLayer WMS” (which is not the same as “standard” TileLayer used for tiles.openstreetmap.org - tiles).
Is this a problem or can the plugin be used to set custom headers for Non-WMS Tileserves too?