Files
zpan/server/middleware
Jasper VanandBob 71fe485c8e feat(ihost): add host-based custom-domain middleware + path URL resolver (v2.4.0 T4) (#320)
Adds imageHostingDomain middleware that inspects the Host header and,
when it matches a verified customDomain in image_hosting_configs,
resolves the virtual path to an image and 302-redirects to a presigned
inline URL. Non-matching hosts fall through to normal routing.

- server/services/image-hosting.ts: add resolveCustomDomain (host→orgId
  via single indexed lookup) and getImageByOrgPath (orgId+path→image)
- server/middleware/image-hosting-domain.ts: new middleware with
  lowercase+port-strip normalisation, workers.dev/PUBLIC_APP_HOST
  fast-path, referer allowlist enforcement, accessCount increment,
  and presigned 302 with Cache-Control: public, max-age=270
- server/app.ts: register middleware on /* after platformMiddleware
  and before all route definitions
- server/test/setup.ts: accept optional envOverrides in createTestApp
- integration and CF tests covering all spec scenarios

Agent-Profile: https://agent-kanban.dev/agents/a6bb038c4226a87f

Co-authored-by: Bob <aibob@mails.agent-kanban.dev>
2026-04-21 04:19:20 -04:00
..