feat(maps): MAP_EXTRA_CONNECT_HOSTS adds the operator's map hosts to the CSP

A GL map fetches its tiles and its style, so a template on a host of the
operator's own (a self-hosted tile server) was refused by connect-src while
Leaflet drew it as images. The new variable lists such hosts; each entry
becomes an https source in connect-src and the same list reaches the client
as map_extra_connect_hosts in the app config, so the renderer choice and the
policy can never disagree.

The variable is owned by readEnv() like the rest of the maps namespace and
read once when the middleware is applied. The boot refuses an entry outside
the shared grammar; a path that skips the boot check drops it, so a bad
value never widens the policy. Unset, the CSP and the app config are as
before apart from an empty list.

Documented in .env.example, docker-compose.yml, the Helm values and
ConfigMap and the wiki. Making room for the app config field shrinks
auth.service.ts by one line, and its size baseline follows.
This commit is contained in:
Maurice
2026-11-30 14:23:55 +01:00
parent 6c68f6ebec
commit 51dc0e6a82
16 changed files with 179 additions and 9 deletions
+2
View File
@@ -90,6 +90,8 @@ DEMO_MODE=false # Demo mode: resets data hourly
# AMAP_API_SECRET= # The private secret (数字签名) of that key. Required exactly when the key was created with signing enabled, because such a key rejects every unsigned request. Leave unset otherwise.
# AMAP_API_BASE=https://restapi.amap.com # Send the Amap calls through an egress proxy, a cache or a gateway that speaks the same API instead of restapi.amap.com directly. (default: https://restapi.amap.com)
# MAP_EXTRA_CONNECT_HOSTS=tiles.example.com # Hosts of your own map tiles or vector styles that the GL maps (MapLibre, Mapbox) may load, comma-separated, e.g. a self-hosted tile server. Each entry is a host name (tiles.example.com), optionally with a port (tiles.example.com:8443) or as a wildcard over its subdomains (*.tiles.example.com); https is implied, so no scheme or path. They are added to the Content-Security-Policy and told to the app, which otherwise draws a map template on such a host with the classic 2D map. An entry that is not a plain host name aborts startup. Read once at startup. (default: none)
# TRANSIT_API_URL=https://api.transitous.org # Base URL of the transit routing API the server proxies to. Point it at your own MOTIS instance to keep transit searches off third-party servers. A trailing slash is stripped. (default: https://api.transitous.org)
# TREK_PLACE_PHOTO_DIR= # Directory for cached Google place photos, e.g. a dedicated volume. Unset, they live in uploads/photos/google. Read once at startup. (default: uploads/photos/google)