mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
fix(offline): the osm-de and stadia prefetch was CSP-blocked and the opening view stayed grey (#2180)
connect-src never listed tile.openstreetmap.de or tiles.stadiamaps.com, so every prefetch fetch was refused before the service worker saw it, while the swallowed error still counted as a cached tile. Both hosts are allowed now and only reached tiles count. The prefetch rectangle is also widened to the screen the fitBounds view fills, on the raster and the vector path alike; the places extent alone left grey bands beside a north-south trip.
This commit is contained in:
@@ -198,6 +198,11 @@ export function applyGlobalMiddleware(
|
||||
// retired the a/b/c/d shards (#1733). The sharded hosts stay listed
|
||||
// for tile templates users saved before that.
|
||||
"https://tile.openstreetmap.org", "https://*.tile.openstreetmap.org",
|
||||
// The other two raster presets TREK ships. `mode: 'no-cors'` relaxes
|
||||
// CORS, not CSP, so without these the tile prefetch is refused in the
|
||||
// document and never reaches the Service Worker that would cache it
|
||||
// (#2180). routing.openstreetmap.de below is a different host.
|
||||
"https://tile.openstreetmap.de", "https://tiles.stadiamaps.com",
|
||||
"https://unpkg.com", "https://open-meteo.com", "https://api.open-meteo.com",
|
||||
"https://geocoding-api.open-meteo.com", "https://api.frankfurter.dev",
|
||||
"https://router.project-osrm.org/route/v1/", "https://routing.openstreetmap.de/",
|
||||
|
||||
@@ -33,6 +33,25 @@ describe('global CSP: OpenStreetMap tile hosts (#1733)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('global CSP: the other shipped raster presets (#2180)', () => {
|
||||
it('allows tile.openstreetmap.de', async () => {
|
||||
// The prefetcher fetches tiles with mode 'no-cors', which relaxes CORS and
|
||||
// nothing else: a host missing here is refused in the document, so the
|
||||
// Service Worker never sees the request and caches no tile at all.
|
||||
expect(await connectSrcSources()).toContain('https://tile.openstreetmap.de');
|
||||
});
|
||||
|
||||
it('allows tiles.stadiamaps.com', async () => {
|
||||
expect(await connectSrcSources()).toContain('https://tiles.stadiamaps.com');
|
||||
});
|
||||
|
||||
it('keeps the routing host, which is a different host and covers nothing here', async () => {
|
||||
// routing.openstreetmap.de was on the list all along and looks close enough
|
||||
// to hide the gap: a CSP source matches a host, not a suffix of one.
|
||||
expect(await connectSrcSources()).toContain('https://routing.openstreetmap.de/');
|
||||
});
|
||||
});
|
||||
|
||||
describe('global CSP: script-src', () => {
|
||||
it("allows 'wasm-unsafe-eval' so the WASM decoders keep running", async () => {
|
||||
expect(await directiveSources('script-src')).toContain("'wasm-unsafe-eval'");
|
||||
|
||||
Reference in New Issue
Block a user