nazirov91 / ra-strapi-rest

React Admin data provider for Strapi.js
125 stars 40 forks source link

Get Entire File Url #19

Closed Ethanpolley closed 4 years ago

Ethanpolley commented 4 years ago

By Default, when strapi is returning the url to an image it only returns beginning with the "/uploads/[id]". Is there anyway to get the entire url to return so that we can use the ImageField Elements in ReactAdmin?

nazirov91 commented 4 years ago

@Ethanpolley You can still use the ImageField element without the entire URL.

<ImageField source="<Name_of_the_image_field>" src="url" />

For example,

<ImageField source="images" src="url" />

Is ImageField element currently not working for you or do you have any specific need to utilize the full image URL?

Also, having the ID of the image, you could easily add the localhost:1337 to the beginning, which would then be the full image URL.

http://localhost:1337/uploads/0467e62f8dd94652928d9150f9b87476.png
Ethanpolley commented 4 years ago

The issue is that i am running my react app from port 3000 (so the link is localhost:3000), but I am running my strapi api from port 1337. Thus, when I load the image field, it tries to access the photos from localhost:3000/uploads/[file_id] instead of from the strapi api, localhost:1337/uploads/[file_id]

nazirov91 commented 4 years ago

Do you have this "proxy": "http://localhost:1337" in your package.json of your react app?

Ethanpolley commented 4 years ago

That Worked! You are a miracle worker thank you so much!

nazirov91 commented 4 years ago

No problem. Good luck!

PvtAnimalMother commented 3 years ago

How can i add proxy to production build? http-proxy-middleware doesnt work image image