feat(maps): one shared list of the shipped tile hosts for the CSP and the client

A GL map fetches its style and its tiles, so it can only draw from a host
the server's connect-src names. The raster presets and OpenFreeMap were
written out in the middleware while the client kept its own idea of them,
and nothing held the two together.

The hosts, their reasons and the default OpenFreeMap style now live in
shared/src/maps/map-defaults.ts. The middleware builds those sources from
the list, and the client takes the default style from it, so the renderer
choice the next steps add reads the same hosts the policy allows.

The policy an install sends stays byte for byte the same: a test pins the
whole connect-src in its order.
This commit is contained in:
Maurice
2026-11-30 14:33:05 +01:00
parent b27b3f6563
commit d8a93af2f5
6 changed files with 150 additions and 51 deletions
+6 -1
View File
@@ -1,3 +1,9 @@
import { OPENFREEMAP_DEFAULT_STYLE } from '@trek/shared'
// The server builds its CSP from the same shared map defaults, so the style a
// MapLibre map falls back to is always one the policy lets it fetch.
export { OPENFREEMAP_DEFAULT_STYLE }
export type GlMapProvider = 'mapbox-gl' | 'maplibre-gl'
export interface GlStylePreset {
@@ -7,7 +13,6 @@ export interface GlStylePreset {
}
export const MAPBOX_DEFAULT_STYLE = 'mapbox://styles/mapbox/standard'
export const OPENFREEMAP_DEFAULT_STYLE = 'https://tiles.openfreemap.org/styles/liberty'
export const MAPBOX_STYLE_PRESETS: GlStylePreset[] = [
{ name: 'Mapbox Standard', url: MAPBOX_DEFAULT_STYLE, tags: ['3D', 'Apple-like'] },