From 55006ffc3b5c66d51636853e15fa702da5185dc9 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 20 May 2026 11:23:50 +0200 Subject: 🐛 force referrerPolicy for OpenStreetMap tile access MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/static/gis/js/OLMapWidget.js | 14 +++++++++++++- ishtar_common/static/js/ishtar-map.js | 12 +++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) (limited to 'ishtar_common/static') diff --git a/ishtar_common/static/gis/js/OLMapWidget.js b/ishtar_common/static/gis/js/OLMapWidget.js index 22047b86d..bdc34593c 100644 --- a/ishtar_common/static/gis/js/OLMapWidget.js +++ b/ishtar_common/static/gis/js/OLMapWidget.js @@ -179,7 +179,19 @@ ol_ext_inherits(GeometryTypeControl, ol.control.Control); } } if (!options.base_layer) { - this.options.base_layer = new ol.layer.Tile({source: new ol.source.OSM()}); + this.options.base_layer = new ol.layer.Tile({ + source: new ol.source.OSM({ + // remove in when switching to OL>= 10.6.1 -> new ol.source.OSM() + tileLoadFunction: (imageTile, src) => { + const img = imageTile.getImage(); + // Set the per-image referrer policy before assigning the src + if (img && 'referrerPolicy' in img) { + img.referrerPolicy = 'origin-when-cross-origin'; + } + img.src = src; + } + }) + }); } this.map = this.createMap(); diff --git a/ishtar_common/static/js/ishtar-map.js b/ishtar_common/static/js/ishtar-map.js index ec11244a0..3b2bed785 100644 --- a/ishtar_common/static/js/ishtar-map.js +++ b/ishtar_common/static/js/ishtar-map.js @@ -191,7 +191,17 @@ var TrackPositionControl = (function (Control) { /* base layers */ var source_osm = function(options){ - options["source"] = new ol.source.OSM(); + options["source"] = new ol.source.OSM({ + // remove in when switching to OL>= 10.6.1 -> new ol.source.OSM() + tileLoadFunction: (imageTile, src) => { + const img = imageTile.getImage(); + // Set the per-image referrer policy before assigning the src + if (img && 'referrerPolicy' in img) { + img.referrerPolicy = 'origin-when-cross-origin'; + } + img.src = src; + } + }); return new ol.layer.Tile(options); }; -- cgit v1.2.3