image icon indicating copy to clipboard operation
image copied to clipboard

Uploadcare: Optional default URL prefix

Open aaronLejeune opened this issue 1 year ago • 4 comments

Problem: There is no option to disable the URL prefix in the UploadCare settings.

It would be nice to have an option in the nuxt.config.js where if cndURL is false, there is no URL prefix.

aaronLejeune avatar Feb 16 '24 16:02 aaronLejeune

If you pass / as a URL, does it behave as you wish?

danielroe avatar Feb 16 '24 20:02 danielroe

Sadly, not.. the generated url will look like this: <img src="/https://ucarecdn.com/5d...53/-/format/auto/-/quality/smart/-/resize/2560x/" with this config image: { uploadcare: { cdnURL: '/' } }, I've found no workaround aside from editing the code :)

aaronLejeune avatar Feb 22 '24 13:02 aaronLejeune

Please let me know if there is anything I can do :)

aaronLejeune avatar Feb 26 '24 08:02 aaronLejeune

seems to work fine for me

CleanShot 2024-03-07 at 00 40 27@2x

https://stackblitz.com/edit/github-kzrcuy?file=nuxt.config.ts,app.vue

danielroe avatar Mar 07 '24 00:03 danielroe

Closing as I can't reproduce the original bug and I believe this feature is already implemented, but please do feel free to provide a reproduction of the original issue and we can definitely reopen.

danielroe avatar Mar 18 '24 15:03 danielroe

Sorry for the late response! Here is a reproduction of the issue:

Screenshot 2024-04-05 at 11 15 41

https://stackblitz.com/edit/github-kzrcuy-6sn53l?file=app.vue,server%2Fapi%2FheadlessCMS.ts,server%2Ftsconfig.json

As you can see, a " / " is always added at the start. Since I am using a headless CMS (Strapi), it already return the full path: (meaning nothing needs to be added in front of the url)


{
  "imageUrl": "https://ucarecdn.com/ed47ee7c-e0c6-41b3-9536-debcfd81afa1/"
}

Solution: If we can set the CDNUrl prefix to false, nothing will be added in front of the already existing URL.

aaronLejeune avatar Apr 05 '24 09:04 aaronLejeune

Hey @danielroe , feel free to let me know if I need to clarify a bit more ;)

aaronLejeune avatar Apr 12 '24 07:04 aaronLejeune

Oh, I see - if the returned data from CDN already has a protocol. I think the fix instead should be simply not to prefix with cdNURL in that case.

We can test with utilities provided from ufo.

danielroe avatar Apr 22 '24 10:04 danielroe