-
Notifications
You must be signed in to change notification settings - Fork 300
Open
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
src
is returned as-is or behavior is ambiguous/bypasses Cloudimage whenbaseURL
is 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
baseURL
should 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
baseURL
optional. - URL construction:
- If
src
is absolute ORbaseURL
is missing:joinURL(CDN_BASE, src) + query
- Else (relative
src
+ providedbaseURL
):joinURL(CDN_BASE, baseURL, src) + query
- If
- Compute CDN base when
cdnURL
is unset:https://{token}.cloudimg.io/{apiVersion}
- Dev warning only when both
token
andcdnURL
are missing.
Metadata
Metadata
Assignees
Labels
No labels