strapi icon indicating copy to clipboard operation
strapi copied to clipboard

Fix/strapi media url

Open laszlo-san opened this issue 5 months ago • 2 comments

  • 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)

laszlo-san avatar Jul 07 '25 10:07 laszlo-san

Deploy request for nuxt-strapi-module pending review.

Visit the deploys page to approve it

Name Link
Latest commit 18fbfe9e73091e58e35f74303e986d21f7b3417a

netlify[bot] avatar Jul 07 '25 10:07 netlify[bot]

@laszlo-san is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Jul 07 '25 10:07 vercel[bot]