From f97aeb696cf7e902ff1483113c46c51c2b652498 Mon Sep 17 00:00:00 2001 From: quytranDF Date: Sat, 21 Sep 2024 23:50:57 +0700 Subject: [PATCH] fix(map): encode the api key in uri debug --- src/modules/maps/services/providers/mapbox.service.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/maps/services/providers/mapbox.service.ts b/src/modules/maps/services/providers/mapbox.service.ts index 2993c9a..bee3b53 100644 --- a/src/modules/maps/services/providers/mapbox.service.ts +++ b/src/modules/maps/services/providers/mapbox.service.ts @@ -17,7 +17,7 @@ export class MapBoxService implements IMapService { const { address, key } = request.params; const url = `${this.MAPBOX_GEOCODE_API_URL}/forward?q=${encodeURIComponent( address, - )}&access_token=${key}`; + )}&access_token=${encodeURIComponent(key)}`; try { const response = await axios.get(url); @@ -51,7 +51,11 @@ export class MapBoxService implements IMapService { `${destination.lng},${destination.lat}`, ].join(';'); - const url = `${this.MAPBOX_OPTIMIZED_ROUTE_API_URL}/mapbox/driving/${coordinates}?source=first&destination=last&roundtrip=false&access_token=${key}&overview=full`; + const url = `${ + this.MAPBOX_OPTIMIZED_ROUTE_API_URL + }/mapbox/driving/${coordinates}?source=first&destination=last&roundtrip=false&access_token=${encodeURIComponent( + key, + )}&overview=full`; try { const response = await axios.get(url);