GPX Proxy
File: app/api/gpx/route.ts
GET /api/gpx
Proxies GPX files from bttpirineus.org to bypass CORS restrictions.
Parameters
| Parameter | Required | Description |
|---|---|---|
url | Yes | Full or relative URL to a .gpx file |
dl | No | Set to 1 to trigger file download instead of inline display |
Host allowlist
Only these hostnames are permitted:
www.bttpirineus.orgbttpirineus.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: addsContent-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
| Status | Condition |
|---|---|
| 400 | Missing url parameter or invalid URL |
| 403 | Hostname not in allowlist |
| 502 | Upstream 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"