Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/components/map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import type maplibregl from 'maplibre-gl';
import 'maplibre-gl/dist/maplibre-gl.css';

import { throttle } from 'throttle-debounce';
import { getValhallaUrl, buildHeightRequest } from '@/utils/valhalla';
import {
getValhallaUrl,
buildHeightRequest,
VALHALLA_CLIENT_HEADERS,
} from '@/utils/valhalla';
import { buildHeightgraphData } from '@/utils/heightgraph';
import HeightGraph from '@/components/heightgraph';
import { DrawControl } from './draw-control';
Expand Down Expand Up @@ -287,7 +291,10 @@ export const MapComponent = () => {
try {
const response = await fetch(`${getValhallaUrl()}/height`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
headers: {
'Content-Type': 'application/json',
...VALHALLA_CLIENT_HEADERS,
},
body: JSON.stringify(buildHeightRequest([[lat, lng]])),
});

Expand Down Expand Up @@ -340,7 +347,10 @@ export const MapComponent = () => {
try {
const response = await fetch(`${getValhallaUrl()}/height`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
headers: {
'Content-Type': 'application/json',
...VALHALLA_CLIENT_HEADERS,
},
body: JSON.stringify(heightPayloadNew),
});

Expand Down
6 changes: 4 additions & 2 deletions src/components/route-planner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const TilesControl = lazy(() =>
import('./tiles/tiles').then((module) => ({ default: module.TilesControl }))
);
import { useCommonStore } from '@/stores/common-store';
import { getValhallaUrl } from '@/utils/valhalla';
import { getValhallaUrl, VALHALLA_CLIENT_HEADERS } from '@/utils/valhalla';
import {
Sheet,
SheetContent,
Expand Down Expand Up @@ -61,7 +61,9 @@ export const RoutePlanner = () => {
} = useQuery({
queryKey: ['lastUpdate'],
queryFn: async () => {
const response = await fetch(`${getValhallaUrl()}/status`);
const response = await fetch(`${getValhallaUrl()}/status`, {
headers: VALHALLA_CLIENT_HEADERS,
});
const data = await response.json();
return new Date(data.tileset_last_modified * 1000);
},
Expand Down
6 changes: 5 additions & 1 deletion src/hooks/use-directions-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
buildDirectionsRequest,
parseDirectionsGeometry,
showValhallaWarnings,
VALHALLA_CLIENT_HEADERS,
} from '@/utils/valhalla';
import { forward_geocode, parseGeocodeResponse } from '@/utils/nominatim';
import { filterProfileSettings } from '@/utils/filter-profile-settings';
Expand Down Expand Up @@ -48,7 +49,10 @@ async function fetchDirections() {
});

const response = await fetch(`${getValhallaUrl()}/route?${params}`, {
headers: { 'Content-Type': 'application/json' },
headers: {
'Content-Type': 'application/json',
...VALHALLA_CLIENT_HEADERS,
},
});

if (!response.ok) {
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/use-isochrones-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
getValhallaUrl,
buildIsochronesRequest,
showValhallaWarnings,
VALHALLA_CLIENT_HEADERS,
} from '@/utils/valhalla';
import {
reverse_geocode,
Expand Down Expand Up @@ -52,6 +53,7 @@ async function fetchIsochrones() {
const response = await fetch(`${getValhallaUrl()}/isochrone?${params}`, {
headers: {
'Content-Type': 'application/json',
...VALHALLA_CLIENT_HEADERS,
},
});

Expand Down
6 changes: 5 additions & 1 deletion src/hooks/use-optimized-route-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
buildOptimizedRouteRequest,
parseDirectionsGeometry,
showValhallaWarnings,
VALHALLA_CLIENT_HEADERS,
} from '@/utils/valhalla';
import { filterProfileSettings } from '@/utils/filter-profile-settings';
import { useCommonStore } from '@/stores/common-store';
Expand Down Expand Up @@ -55,7 +56,10 @@ export function useOptimizedRouteQuery() {
});

const response = await fetch(
`${getValhallaUrl()}/optimized_route?${params}`
`${getValhallaUrl()}/optimized_route?${params}`,
{
headers: VALHALLA_CLIENT_HEADERS,
}
);

if (!response.ok) {
Expand Down
4 changes: 4 additions & 0 deletions src/utils/valhalla.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import { getBaseUrl } from './base-url';

export const getValhallaUrl = () => getBaseUrl();

export const VALHALLA_CLIENT_HEADERS = {
'X-Client-Id': 'public-web-app',
} as const;

export const buildLocateRequest = (
latLng: { lat: number; lng: number },
profile: Profile
Expand Down
Loading