local-cdn:// stub URLs without writing to disk or calling a cloud provider.
Why
Use Local for safe development and Jest without R2 credentials, disk paths, or outbound object-storage traffic. The sameCDNType contract applies so callers work unchanged when you switch to Cloudflare R2 in production.
Setup
-
tooling-cdn-localis already a workspace dependency ofapps/backend. -
Configure
tools.cdninapps/backend/src/configuration/development.tsandtest.ts:
- No provider env vars are required.
- Verify:
Local observability
Operations log through feature loggercdn-local:
Inspect backend stdout (Pino in dev) after an upload mutation.
Behavior vs production
Limitation
Stub URLs do not resolve in<img src>. For fetchable images in dev, use R2 in a staging environment or accept broken previews locally. Filesystem-backed local CDN is a possible future enhancement — not included in the boilerplate today.
Adding a new bucket constant
Local config has nobuckets[] list, but callers still pass logical bucket names (e.g. CDN_BUCKET_PROFILE_PICTURES from apps/backend/src/constants/cdn.ts) for API consistency. See CDN overview for the full bucket recipe.
Gotchas
tools.cdnmust appear in config for the tool to load — omitting it disables uploads entirely.- Local does not validate bucket names against a config list; unknown names still return stub URLs.
- Do not point production traffic at Local.
What’s next?
- Cloudflare R2 — production object storage
- CDN overview — contract and extension patterns
- Configuration — swapping pluggable tools
