Adds apps/planner/app/routes/api.overpass.ts — a same-origin, rate-limited server-side proxy that forwards Overpass QL to the upstream endpoint configured via OVERPASS_URL (default: overpass.private.coffee). Motivation: - private.coffee's best-practices require a meaningful User-Agent identifying the project. Browsers cannot set User-Agent on fetch() (forbidden header), so the request has to originate server-side. - Collaborative sessions commonly have N clients pan/zoom the same map, so the same bbox query arrives multiple times within seconds. - Setting up the proxy now lets us swap OVERPASS_URL to a self-hosted Overpass later without client changes. What the proxy does: - Sets User-Agent "trails.cool Planner (https://trails.cool; legal@trails.cool)" - Enforces same-origin via the Origin header - Rate-limits per client IP (120 req/min) - In-memory LRU cache of upstream responses keyed on the form-encoded body (TTL 10 min, max 200 entries) - Coalesces concurrent misses for the same key so N simultaneous clients in one session incur exactly one upstream call Client change: apps/planner/app/lib/overpass.ts POSTs to /api/overpass instead of iterating over public Overpass endpoints. Fallback list removed; resilience is now the proxy's responsibility. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
10 lines
377 B
TypeScript
10 lines
377 B
TypeScript
import { type RouteConfig, index, route } from "@react-router/dev/routes";
|
|
|
|
export default [
|
|
index("routes/home.tsx"),
|
|
route("new", "routes/new.tsx"),
|
|
route("api/sessions", "routes/api.sessions.ts"),
|
|
route("api/route", "routes/api.route.ts"),
|
|
route("api/overpass", "routes/api.overpass.ts"),
|
|
route("session/:id", "routes/session.$id.tsx"),
|
|
] satisfies RouteConfig;
|