mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-22 23:01:48 +00:00
Fix Nominatim User-Agent and improve error diagnostics
- Update User-Agent from old NOMAD URL to TREK - Include HTTP status code and response body in Nominatim error messages
This commit is contained in:
@@ -43,7 +43,7 @@ interface GooglePlaceDetails extends GooglePlaceResult {
|
|||||||
|
|
||||||
// ── Constants ────────────────────────────────────────────────────────────────
|
// ── Constants ────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const UA = 'TREK Travel Planner (https://github.com/mauriceboe/NOMAD)';
|
const UA = 'TREK Travel Planner (https://github.com/mauriceboe/TREK)';
|
||||||
|
|
||||||
// ── Photo cache ──────────────────────────────────────────────────────────────
|
// ── Photo cache ──────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -89,7 +89,10 @@ export async function searchNominatim(query: string, lang?: string) {
|
|||||||
const response = await fetch(`https://nominatim.openstreetmap.org/search?${params}`, {
|
const response = await fetch(`https://nominatim.openstreetmap.org/search?${params}`, {
|
||||||
headers: { 'User-Agent': UA },
|
headers: { 'User-Agent': UA },
|
||||||
});
|
});
|
||||||
if (!response.ok) throw new Error('Nominatim API error');
|
if (!response.ok) {
|
||||||
|
const text = await response.text().catch(() => '');
|
||||||
|
throw new Error(`Nominatim API error: ${response.status} ${response.statusText}${text ? ' - ' + text.substring(0, 200) : ''}`);
|
||||||
|
}
|
||||||
const data = await response.json() as NominatimResult[];
|
const data = await response.json() as NominatimResult[];
|
||||||
return data.map(item => ({
|
return data.map(item => ({
|
||||||
google_place_id: null,
|
google_place_id: null,
|
||||||
|
|||||||
Reference in New Issue
Block a user