Skip to content

fix(uploadcare): omit base when resolved URL is returned#1254

Merged
danielroe merged 7 commits into
nuxt:mainfrom
aaronLejeune:patch-1
Apr 22, 2024
Merged

fix(uploadcare): omit base when resolved URL is returned#1254
danielroe merged 7 commits into
nuxt:mainfrom
aaronLejeune:patch-1

Conversation

@aaronLejeune

Copy link
Copy Markdown
Contributor

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.

Problem:
There is no option to provide a full link in the src attribute.
It is either the custom cdnURL or the default as a prefix.

It would be nice to have an option in the nuxt.config.js where if cndURL is false, there is no URL prefix.
@aaronLejeune aaronLejeune changed the title Optional default URL prefix Uploadcare: Optional default URL prefix Feb 16, 2024
@danielroe

Copy link
Copy Markdown
Member

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

@aaronLejeune

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor Author

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

@danielroe

danielroe commented Mar 7, 2024

Copy link
Copy Markdown
Member

@danielroe

Copy link
Copy Markdown
Member

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 danielroe closed this Mar 18, 2024
@aaronLejeune

aaronLejeune commented Apr 5, 2024

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor Author

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

@danielroe danielroe reopened this Apr 22, 2024
@danielroe

Copy link
Copy Markdown
Member

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 danielroe changed the title Uploadcare: Optional default URL prefix fix(uploadcare): omit base when resolved URL is returned Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants