Add CORS header to Element's map_style.json for Element Desktop

Element Desktop (Electron) loads the location-sharing map style from a
`vector://vector` origin, so fetching map_style.json from the Element
domain is a cross-origin request. Without an Access-Control-Allow-Origin
header, the request is blocked and maps fail to load with "This homeserver
is not configured correctly to display maps".

Add a dedicated Traefik router for map_style.json that attaches an
Access-Control-Allow-Origin header (configurable via
matrix_client_element_location_sharing_map_style_access_control_allow_origin,
defaulting to `*`). It is only defined when location sharing is enabled.

Fixes #2291

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Slavi Pantaleev
2026-07-13 08:58:52 +03:00
parent d0f877fb86
commit b32272ef40
2 changed files with 21 additions and 0 deletions
@@ -346,6 +346,10 @@ matrix_client_element_configuration: "{{ matrix_client_element_configuration_def
# How to host your own map tile server: https://matrix.org/docs/guides/map-tile-server
matrix_client_element_location_sharing_enabled: false
# Controls the value of the `Access-Control-Allow-Origin` header attached to responses for `map_style.json`.
# Element Desktop loads the map style from a `vector://vector` origin, so cross-origin access needs to be allowed.
matrix_client_element_location_sharing_map_style_access_control_allow_origin: "*"
# Default Element location sharing map style configuration template which covers the generic use case.
# You can customize it by controlling the various variables inside it.
#