Skip to content

Respect nominatim.openstreetmap.org usage policy #458

@edaigle

Description

@edaigle

Adding a new trail by uploading a GPX to the form on /settings/export fails (error message as in #412 although unsure if same root cause). After some digging, it fails because the backend gets a 403 from Nominatim when trying to geocode the area in stores/search_store.ts:searchLocationReverse:


const r = await fetch(`${nominatimURL}/reverse?lat=${lat}&lon=${lon}&format=geojson&addressdetails=1`, {
        method: "GET",
    });

....

Response {
  status: 403,
  statusText: 'Forbidden',
  headers: Headers {
    server: 'nginx',
    date: 'Wed, 13 Aug 2025 22:48:48 GMT',
    'content-type': 'text/html',
    'content-length': '941',
    connection: 'keep-alive',
    'keep-alive': 'timeout=20',
    etag: '"6731053f-3ad"'
  },
  body: ReadableStream { locked: false, state: 'readable', supportsBYOB: true },
  bodyUsed: false,
  ok: false,
  redirected: false,
  type: 'basic',
  url: 'https://nominatim.openstreetmap.org/reverse?lat=49.59505&lon=-121.12443&format=geojson&addressdetails=1'
}

This is because the app does not have a specific User-Agent as required by the API's usage policy. Adding a header fixes the issue:

const r = await fetch(`${nominatimURL}/reverse?lat=${lat}&lon=${lon}&format=geojson&addressdetails=1`, {
        method: "GET",
        headers: {"User-Agent": "My Fancy Wanderer User agent"}
    });

As best I can tell this doesn't happen when uploading a GPX to the individual New Trail UI because the request is then made on the frontend and inherits the browser user agent, which keeps Nominatim happy.

I can open a PR for this but assume there should first be discussion as to what the header should be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestNew feature or requestpending publicationThe issue is fixed and will be included in the next patch

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions