diff --git a/package.json b/package.json index 0889ee94..c2cd47ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homepage", - "version": "1.89.0", + "version": "1.89.1", "private": true, "type": "module", "scripts": { diff --git a/src/lib/server/hikesRouting.ts b/src/lib/server/hikesRouting.ts index 90d5f7b4..fb2559f6 100644 --- a/src/lib/server/hikesRouting.ts +++ b/src/lib/server/hikesRouting.ts @@ -57,6 +57,11 @@ const OSRM_PROFILE: Record = { road: 'driving' }; +// Self-hosted BRouter instance (see the `brouter` package + systemd service). +// Defaults to the localhost server so production needs no extra config; override +// with the BROUTER_URL env var (e.g. to point at a remote instance in dev). +const BROUTER_URL = (process.env.BROUTER_URL || 'http://127.0.0.1:17777').replace(/\/+$/, ''); + async function fetchJson(url: string, signal: AbortSignal): Promise { try { const res = await fetch(url, { @@ -121,7 +126,7 @@ async function routeBrouter( signal: AbortSignal ): Promise | null> { const url = - `https://brouter.de/brouter?lonlats=${a.lng},${a.lat}|${b.lng},${b.lat}` + + `${BROUTER_URL}/brouter?lonlats=${a.lng},${a.lat}|${b.lng},${b.lat}` + `&profile=${BROUTER_PROFILE[profile]}&alternativeidx=0&format=geojson`; const json = await fetchJson(url, signal); if (!json?.features?.[0]?.geometry?.coordinates) return null;