-
Notifications
You must be signed in to change notification settings - Fork 313
Closed
Description
Cloudimage: Absolute URLs bypass CDN and baseURL requirement creates friction with multi-origin backends
Description
In real-world setups, images often come as full URLs from multiple backends (CMS/DAM/microservices). The current Cloudimage provider requires a single baseURL and returns absolute src as-is, which:
- Bypasses the Cloudimage CDN for absolute URLs.
- Forces consumers to strip origins or maintain per-domain mappings.
- Doesn't scale when multiple origins exist.
This leads to unnecessary complexity and inconsistent behavior.
Steps to Reproduce
Scenario 1: No baseURL, src is absolute
- Configure Cloudimage with
token: "demo",apiVersion: "v7", nobaseURL. - Call:
getImage("https://example.com/image.jpg", { modifiers: { width: 200 } })
- Observe the returned URL.
Scenario 2: baseURL set, src is absolute
- Configure Cloudimage with
token: "demo",apiVersion: "v7",baseURL: "_sl_". - Call:
getImage("https://example.com/image.jpg", { modifiers: { width: 200 } })
- Observe the returned URL.
Actual Behavior
- Absolute
srcis returned as-is or behavior is ambiguous/bypasses Cloudimage whenbaseURLis set, pushing origin-stripping logic to the app.
Expected Behavior
- Absolute sources (or relative sources without
baseURL) should be routed via the Cloudimage CDN base:https://{token}.cloudimg.io/{apiVersion}/https://example.com/image.jpg?width=200
baseURLshould be optional and used only when joining a relativesrc.
Impact
- Extra app-side logic to normalize/strip origins.
- Fragile regex/mapping per backend domain.
- Inconsistent CDN usage across inputs.
- Poor scalability when integrating multiple services/domains.
Proposed Solution
- Make
baseURLoptional. - URL construction:
- If
srcis absolute ORbaseURLis missing:joinURL(CDN_BASE, src) + query - Else (relative
src+ providedbaseURL):joinURL(CDN_BASE, baseURL, src) + query
- If
- Compute CDN base when
cdnURLis unset:https://{token}.cloudimg.io/{apiVersion} - Dev warning only when both
tokenandcdnURLare missing.
Metadata
Metadata
Assignees
Labels
No labels