unable to download tiles (403 forbidden)
Hello,
I'm a developper As a developper, I now have to work on an existing application with a setup of leaflet using OSM that is already in place. The application is displaying a map on a page (client side application using Angular). If I deploy the code somewhere, the map is working fine. But during the development phase, the project runs in local (served on localhost:4200). But in local the map does not load and I recently got an application which is not working at all.
I can see many calls failing in the network tab of the debugger. I can see that previous developpers configured a map with leaflet using osm.
It works in prod but in local I'm getting the app can't load tiles because it gets an HTTP 403 forbidden when loading tiles.
I don't understand why.
The following as a reponse.
Below you can find a example of a call done for a tile that is failing:
curl 'https://a.tile.openstreetmap.org/18/134243/87922.png' \<br>
-H 'authority: a.tile.openstreetmap.org' \<br>
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36' \<br>
-H 'accept: image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8' \
-H 'sec-fetch-site: cross-site' \<br>
-H 'sec-fetch-mode: no-cors' \<br>
-H 'sec-fetch-dest: image' \<br>
-H 'referer: http://localhost:4200/' \<br>
-H 'accept-language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7' \<br>
--compressed
If I change the referer After some more investigation I found that in local it works, works on Safari but it is normal to no be able to load tiles not on Chrome. So the problem seems to come from localhost ?
headers added by the browser.
*UPDATE 1*:<br>
On chrome I can retrieve a tile if the referer if different than localhost.<br>
On Safari it works even with referer is equal to localhost.<br>
It seems to be related to user-agent and/or referer.<br>
I have the impression that osm needs one of OSM is validating those 2 headers (referer/user-agent).<br>
headers: referer and user-agent<br>
If this statement is correct:
- Chrome user agent is not accepted
- localhost referer is not accepted
**Chrome**<br>
version used: Version 99.0.4844.74 (Build officiel) (x86_64)<br>
user-agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36"
**Safari**<br>
version used: Version 15.3 (17612.4.9.1.8)<br>
user-agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15"Safari/605.1.15"
Do you think this is a normal behavior ? If OSM need one of those 2 headers to be validated on the server side, I'm not getting why it does not reconize Chrome user-agent as a valid one. Am I missing something ?