Skip to Content
API ReferenceGPX Proxy

GPX Proxy

File: app/api/gpx/route.ts

GET /api/gpx

Proxies GPX files from bttpirineus.org to bypass CORS restrictions.

Parameters

ParameterRequiredDescription
urlYesFull or relative URL to a .gpx file
dlNoSet to 1 to trigger file download instead of inline display

Host allowlist

Only these hostnames are permitted:

  • www.bttpirineus.org
  • bttpirineus.org

Relative URLs (starting with /) are resolved against https://www.bttpirineus.org.

Response

  • Content-Type: application/gpx+xml
  • Cache-Control: public, max-age=86400 (24 hours)
  • When dl=1: adds Content-Disposition: attachment; filename="..." header

Download tracking

When dl=1 is set, the server fires a PostHog event:

gpx_proxy_downloaded { gpx_url, filename }

Error codes

StatusCondition
400Missing url parameter or invalid URL
403Hostname not in allowlist
502Upstream fetch failed

Examples

# Inline display curl "http://localhost:3000/api/gpx?url=http://www.bttpirineus.org/wp-content/uploads/Falda%20Bassegoda.gpx" # Download curl -O "http://localhost:3000/api/gpx?url=http://www.bttpirineus.org/wp-content/uploads/Falda%20Bassegoda.gpx&dl=1"