Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix(web): send referrer with OpenStreetMap tile requests

himanshucodess2f4a6e55e596
diff --git a/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx b/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx
index 9b76cb62ae..332df4a48e 100644
--- a/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx
@@ -1500,6 +1500,8 @@ const MapCanvas = React.memo(function MapCanvas({
url="https://tile.openstreetmap.org/{z}/{x}/{y}.png"
maxZoom={MAX_MAP_ZOOM}
updateWhenZooming
+ // OSM blocks tile requests without a Referer.
+ referrerPolicy="strict-origin-when-cross-origin"
/>
<MapControls useMap={useMap} />
<MapClusters
diff --git a/web/packages/gallery/components/FileInfo.tsx b/web/packages/gallery/components/FileInfo.tsx
index 96b535dda5..a8b8fe4cc2 100644
--- a/web/packages/gallery/components/FileInfo.tsx
+++ b/web/packages/gallery/components/FileInfo.tsx
@@ -984,7 +984,13 @@ const MapBox: React.FC<MapBoxProps> = ({ location, mapEnabled }) => {
if (!mapRef.current) {
const map = leaflet.map(mapContainer).setView(position, zoom);
map.attributionControl.setPrefix(leafletAttributionPrefix);
- leaflet.tileLayer(urlTemplate, { attribution }).addTo(map);
+ leaflet
+ .tileLayer(urlTemplate, {
+ attribution,
+ // OSM blocks tile requests without a Referer.
+ referrerPolicy: "strict-origin-when-cross-origin",
+ })
+ .addTo(map);
markerRef.current = leaflet.marker(position).addTo(map);
mapRef.current = map;
} else {
diff --git a/web/packages/new/photos/components/EditLocationDialog.tsx b/web/packages/new/photos/components/EditLocationDialog.tsx
index a7a8b8bdb6..21442b10be 100644
--- a/web/packages/new/photos/components/EditLocationDialog.tsx
+++ b/web/packages/new/photos/components/EditLocationDialog.tsx
@@ -435,7 +435,13 @@ const EditableMap: React.FC<EditableMapProps> = ({
const map = leaflet
.map(mapContainer, { zoomControl: false })
.setView(center, zoom);
- leaflet.tileLayer(urlTemplate, { attribution }).addTo(map);
+ leaflet
+ .tileLayer(urlTemplate, {
+ attribution,
+ // OSM blocks tile requests without a Referer.
+ referrerPolicy: "strict-origin-when-cross-origin",
+ })
+ .addTo(map);
mapRef.current = map;
if (hasInitialLocation) {