Skip to content

Commit

Permalink
fix: Add authentication to maplibre tile requests
Browse files Browse the repository at this point in the history
  • Loading branch information
annehaley committed Sep 19, 2024
1 parent 71d9cb0 commit f543ca5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions web/src/components/map/Map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit f543ca5

Please sign in to comment.