Skip to content

Cloudimage: Absolute URLs bypass CDN and baseURL is required (friction with multi-origin backends) #1950

@s8n11c

Description

@s8n11c

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

  1. Configure Cloudimage with token: "demo", apiVersion: "v7", no baseURL.
  2. Call:
    getImage("https://example.com/image.jpg", { modifiers: { width: 200 } })
  3. Observe the returned URL.

Scenario 2: baseURL set, src is absolute

  1. Configure Cloudimage with token: "demo", apiVersion: "v7", baseURL: "_sl_".
  2. Call:
    getImage("https://example.com/image.jpg", { modifiers: { width: 200 } })
  3. Observe the returned URL.

Actual Behavior

  • Absolute src is returned as-is or behavior is ambiguous/bypasses Cloudimage when baseURL 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 relative src.

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 OR baseURL is missing: joinURL(CDN_BASE, src) + query
    • Else (relative src + provided baseURL): joinURL(CDN_BASE, baseURL, src) + query
  • Compute CDN base when cdnURL is unset: https://{token}.cloudimg.io/{apiVersion}
  • Dev warning only when both token and cdnURL are missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions