From 4906e9fab2d93fd7058e4c82cd6e53c94e36f09e Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Mon, 16 Sep 2024 22:33:47 +0000 Subject: [PATCH] fix: Add authentication to maplibre tile requests --- web/src/components/map/Map.vue | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/web/src/components/map/Map.vue b/web/src/components/map/Map.vue index 72ebb78b..1d433266 100644 --- a/web/src/components/map/Map.vue +++ b/web/src/components/map/Map.vue @@ -14,6 +14,7 @@ import "maplibre-gl/dist/maplibre-gl.css"; import ActiveLayers from "./ActiveLayers.vue"; import MapTooltip from "./MapTooltip.vue"; +import { oauthClient } from "@/api/auth"; class VueMapControl implements IControl { _vueElement: HTMLElement; @@ -61,6 +62,16 @@ export default { function createMap() { const newMap = new Map({ container: "mapContainer", + transformRequest: (url) => { + let headers = {}; + if (!url.includes("openstreetmap")) { + headers = oauthClient?.authHeaders; + } + return { + url, + headers, + }; + }, style: { version: 8, sources: {