AnswerBun.com

Basic Authentication in Leaflet

Geographic Information Systems Asked by xenia on January 12, 2021

I’m using Leaflet to display map tiles. The map tiles are loaded from a different site using basic authentication.
So the url template looks like this: L.tileLayer('https://username:[email protected]/tiles/{z}/{x}/{y}.png')

Unfortunately this results in map tiles not loading, since e.g. Internet Explorer just ignores the username and password in web site adresses.

Is there a way to succesfully authenticate the Leaflet map tile requests without using a proxy but still using basic authentication?

2 Answers

Some browsers block links containing credentials, while others even block resources. I am able to load tiles which require HTTP basic authentication using Leaflet on Firefox, but not on Chrome.

See: https://bugs.chromium.org/p/chromium/issues/detail?id=435547

Answered by Francesco Frassinelli on January 12, 2021

Without knowing the tile provider, hard to tell how to best to structure the URL call. A workaround could simply be to use a similar tile service... here's a bunch that show both preview and the L.tileLayer configurations:

https://leaflet-extras.github.io/leaflet-providers/preview/

Answered by GEO-X on January 12, 2021

Add your own answers!

Related Questions

PostGIS ST_Area unexpectedly returns 0

1  Asked on November 26, 2020 by strixcuriosus

     

Geoserver WMS, WFS and Rest difference

2  Asked on November 26, 2020 by boliwe

       

Print identify results QGIS

1  Asked on November 26, 2020

 

Error in overlay – formula not vectorized

1  Asked on November 26, 2020 by bianca-wolf

         

How to calculate the area of overlap of a buffer in ArcMap

1  Asked on November 26, 2020 by tp123abc

   

Hide Layer data source popup

0  Asked on November 26, 2020 by gareth-shedden

         

Torque.js is not working: L.TorqueLayer is not a constructor

1  Asked on November 26, 2020 by juan-salvatore

       

Loading PyQt5 modules from QGIS3/PyQGIS

1  Asked on November 25, 2020 by pat-s

   

Installing QGIS Server on existing Apache/PHP on Windows 10

0  Asked on November 24, 2020 by hubert-djteinboua

       

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir