Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 7 commits into from
Apr 22, 2024

Conversation

aaronLejeune
Copy link
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
Member

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

@aaronLejeune
Copy link
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
Contributor Author

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

@danielroe
Copy link
Member

danielroe commented Mar 7, 2024

@danielroe
Copy link
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
Copy link
Contributor Author

aaronLejeune commented Apr 5, 2024

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
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
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
@danielroe danielroe merged commit d2a2c6f into nuxt:main Apr 22, 2024
1 check passed
@github-actions github-actions bot mentioned this pull request 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