Local tile streaming HTTP 206 route handler (src/app/tiles/[file]/route.ts) #39

Closed
opened 2026-10-14 22:28:34 +00:00 by yuris · 1 comment
Owner

What to build

Refactor src/app/tiles/[file]/route.ts into a robust local HTTP 206 Partial Content streaming endpoint supporting HEAD requests, sanitization of requested byte bounds, and strict file security boundaries against directory traversal.

Technical specifications

  1. Target files:
    • src/app/tiles/[file]/route.ts: Streaming route handler.
  2. Server mechanics:
    • Respond to HEAD requests with Accept-Ranges: bytes and Content-Length.
    • Validate requested byte ranges (bytes=start-end) against actual file size on disk.
    • Block directory traversal attempts (e.g. ../ or encoded equivalents).
    • Return 416 Range Not Satisfiable for invalid ranges.

Acceptance criteria

  • curl -I -H "Range: bytes=0-512" http://localhost:3000/tiles/peat_soil.pmtiles returns 206 Partial Content.
  • HEAD requests return accurate Content-Length without loading the entire archive into memory.
  • Unit tests pass for range boundary conditions and path traversal protection.

Authoritative Specifications & Reference Documentation

### What to build Refactor `src/app/tiles/[file]/route.ts` into a robust local HTTP 206 Partial Content streaming endpoint supporting HEAD requests, sanitization of requested byte bounds, and strict file security boundaries against directory traversal. ### Technical specifications 1. **Target files**: - `src/app/tiles/[file]/route.ts`: Streaming route handler. 2. **Server mechanics**: - Respond to `HEAD` requests with `Accept-Ranges: bytes` and `Content-Length`. - Validate requested byte ranges (`bytes=start-end`) against actual file size on disk. - Block directory traversal attempts (e.g. `../` or encoded equivalents). - Return `416 Range Not Satisfiable` for invalid ranges. ### Acceptance criteria - [ ] `curl -I -H "Range: bytes=0-512" http://localhost:3000/tiles/peat_soil.pmtiles` returns `206 Partial Content`. - [ ] HEAD requests return accurate `Content-Length` without loading the entire archive into memory. - [ ] Unit tests pass for range boundary conditions and path traversal protection. --- ### Authoritative Specifications & Reference Documentation - **Titik Gambut Architecture & Subsystem Contract**: [`docs/ARCHITECTURE.md`](https://git.nokopia.com/yuris/titik-gambut-next/src/branch/main/docs/ARCHITECTURE.md) - **Protomaps PMTiles Specification**: [protomaps/PMTiles GitHub](https://github.com/protomaps/PMTiles) — cloud-optimized single-file vector/raster tile format using HTTP 206 byte-range requests. - **Protomaps Basemaps Style & Docs**: [protomaps.com/docs](https://docs.protomaps.com/basemaps/)
yuris changed title from Issue 26: [Backend] Local tile streaming HTTP 206 route handler (src/app/tiles/[file]/route.ts) to [Backend] Local tile streaming HTTP 206 route handler (src/app/tiles/[file]/route.ts) 2026-10-14 22:31:29 +00:00
yuris changed title from [Backend] Local tile streaming HTTP 206 route handler (src/app/tiles/[file]/route.ts) to Local tile streaming HTTP 206 route handler (src/app/tiles/[file]/route.ts) 2026-10-14 22:38:34 +00:00
Author
Owner

This was generated by AI during triage.

Closed as completed in main (src/app/tiles/[file]/route.ts supports RFC 7233 HTTP 206 Partial Content byte ranges).

> *This was generated by AI during triage.* Closed as completed in main (src/app/tiles/[file]/route.ts supports RFC 7233 HTTP 206 Partial Content byte ranges).
yuris closed this issue 2026-10-15 01:26:11 +00:00
Sign in to join this conversation.
No labels
backend
frontend
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
yuris/titik-gambut-next#39
No description provided.