Fix/strapi media url
- Add URL detection using new URL() constructor
- Return absolute URLs as-is without prepending base URL
- Maintain backward compatibility for relative paths
- Add documentation with examples
Fixes URL malformation in production environments where Strapi Cloud returns full URLs (e.g., https://domain.media.strapiapp.com/image.jpg) instead of relative paths, preventing double-prefixing with base URL.
Types of changes
- [x] Bug fix (a non-breaking change which fixes an issue)
- [ ] New feature (a non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
Description
On self hosted/local dev environments Strapi returns relative paths for media resources, Strapi Cloud hovewer returns an absolute path, thus the url useStrapiMedia would return will be something like https://{strapiURL}/https://{domain}.media.strapiapp.com/path
Checklist:
- [ ] My change requires a change to the documentation.
- [x] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes (if not applicable, please state why)
Deploy request for nuxt-strapi-module pending review.
Visit the deploys page to approve it
| Name | Link |
|---|---|
| Latest commit | 18fbfe9e73091e58e35f74303e986d21f7b3417a |
@laszlo-san is attempting to deploy a commit to the NuxtLabs Team on Vercel.
A member of the Team first needs to authorize it.