Join the Webstudio community

Updated 5 months ago

Images are not rendering when populated from API

At a glance
It's great what I am able to do with API integration in webstudio. But I have some issues with fetching images from API.

I am trying to fetch a collection created in Strapi using "Resource" variable into Webstudio page. When the image is mapped to the "Source" field as URL the image is not getting rendered properly.


By investigating further observed the image URL as follows:
https://localhost:5173/cgi/image/https%3A//inspiring-candy-d5ab9b6954.media.strapiapp.com/imagename.jpg?width=640&quality=80&format=auto

I understand that the root path is getting attached to the original URL path from API.
How do I resolve? Any help is appreciated.
Attachment
image.png
J
S
K
7 comments
Are you using the builder locally by chance? And am I correct in understanding the screenshot shows the right URL but when you inspect the page it shows the local host url?
Yes, I am using the builder locally.
And yes, your understanding is correct. When we inspect, the localhost url is prefixed to the image URL received through API.

It is not just through API. IF you copy paste any external image url in that field, it will not render.
Is this feature on? Disabling might help.
Attachment
Screenshot_2024-09-19_at_15.56.45.png
Talked to an engineer and there should be some env variable you can set. Might take some digging on what exactly but something like env.development file
https://wstd.dev:5173/cgi/image
This solution worked. Thanks buddy.
I couldn't see anything in the URL mentioned. Any insights on what could be the envmt setup to do?
Still wondering if there could anything more into this issue?
Add a reply
Sign up and join the conversation on Discord