feat(cloudimage): make baseURL optional with cdn - #1951
Conversation
|
@s8n11c is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
commit: |
|
would you have a look at the failing tests? 🙏 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1951 +/- ##
=====================================
Coverage 7.08% 7.08%
=====================================
Files 76 76
Lines 3529 3529
Branches 137 137
=====================================
Hits 250 250
Misses 3232 3232
Partials 47 47 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
baseURL optional with cdn
@danielroe I think the problem statement provided by @s8n11c should be the default for all the providers. Not just Cloudimage. This should be the default behavior for the module |
feat(provider/cloudimage): make baseURL optional and route absolute src via CDN
🔗 Linked issue
Resolves #1950 - Cloudimage: Absolute URLs bypass CDN and
baseURLrequirement creates friction with multi-origin backends❓ Type of change
📚 Description
Problem:
In real-world applications, image sources often come as full URLs from multiple backend services (CMS, DAM, microservices). The current Cloudimage provider has two main issues:
srcis an absolute URL, the provider returns it as-is, completely bypassing the Cloudimage CDNbaseURL, but real apps often have images from multiple domains, making it impossible to define one universalbaseURLThis forces developers to:
Solution:
This PR makes the Cloudimage provider more resilient to real-world inputs by:
baseURLoptional: Only used when joining relativesrcpathssrcvalues are now consistently routed through the Cloudimage CDN basesrcis absolute ORbaseURLis missing:joinURL(CDN_BASE, src) + queryjoinURL(CDN_BASE, baseURL, src) + querytokenandcdnURLare missing (truly required inputs)Changes:
src/runtime/providers/cloudimage.ts: Updated URL construction logic and madebaseURLoptionaldocs/content/3.providers/cloudimage.md: Updated documentation to reflect new behaviortest/nuxt/providers.test.ts: Added test cases for absolute URLs and cdnURL-only scenariosBackward Compatibility:
token + baseURLcontinue to work unchangedapiVersionbehavior