Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/osm-weather-map-referrer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ftw": patch
---

The weather location map loads again. OpenStreetMap's volunteer tiles now require a Referer, and the box was sending none.
2 changes: 1 addition & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ <h3>Price bars (top of the chart)</h3>
<script src="/settings/tabs/devices.js?v=catcards2"></script>
<script src="/settings/tabs/loadpoints.js?v=lp2"></script>
<script src="/settings/tabs/price.js?v=zones1"></script>
<script src="/settings/tabs/weather.js?v=tabsplit1"></script>
<script src="/settings/tabs/weather.js?v=osmref1"></script>
<script src="/settings/tabs/batteries.js?v=tabsplit1"></script>
<script src="/settings/tabs/planner.js?v=cvxpy1"></script>
<script src="/settings/tabs/ha.js?v=tabsplit2"></script>
Expand Down
7 changes: 7 additions & 0 deletions web/leaflet-vendor.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ test('weather map loads Leaflet from the vendored copy, not unpkg', () => {
assert.match(weather, /\/vendor\/leaflet\/leaflet\.css/);
});

test('weather map sends a Referer on OSM tiles so volunteer servers do not 403', () => {
assert.match(weather, /tile\.openstreetmap\.org/);
assert.match(weather, /referrerPolicy:\s*"strict-origin-when-cross-origin"/);
const leaflet = readFileSync(join(vendor, 'leaflet.js'), 'utf8');
assert.match(leaflet, /typeof this\.options\.referrerPolicy/);
Comment on lines +18 to +21

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Validate the referrer override in a browser

For FTW pages served with the global Referrer-Policy: no-referrer header, these regex assertions only prove that the option and Leaflet assignment exist; they do not verify that a browser actually sends the Referer or that OSM renders real tiles. The test still passes if the original blocked-tile behavior remains, so this UI fix needs the required human browser inspection of Settings → Weather rather than being treated as behaviorally verified.

AGENTS.md reference: AGENTS.md:L90-L91

Useful? React with 👍 / 👎.

});

test('vendored Leaflet 1.9.4 files are present', () => {
for (const rel of [
'leaflet.js',
Expand Down
4 changes: 4 additions & 0 deletions web/settings/tabs/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,13 @@
if (window._weatherMap) { try { window._weatherMap.remove(); } catch (e) {} window._weatherMap = null; }
var map = L.map(container, { zoomControl: true }).setView([lat, lon], 11);
window._weatherMap = map;
// OSM volunteer tiles 403 when the page sends no Referer. The box
// sends Referrer-Policy: no-referrer on every response, so Leaflet
// must opt these images back in. Origin only; the path stays private.
L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", {
maxZoom: 18,
attribution: "© OpenStreetMap",
referrerPolicy: "strict-origin-when-cross-origin",
}).addTo(map);
var marker = L.marker([lat, lon], { draggable: true }).addTo(map);
function setCoord(la, lo) {
Expand Down