How access image from external source?


#1

I’m developing a client-side based on React what connects to Slim on server-side. I’m doing the following:
<img src={ returnedObject.url } alt={ returnedObject.label } /> on React.
This makes the alt text to be displayed but never the image file. I pasted the returnedObject.url (http://8080/src/images/img.jpg) on the browser (Chromium) what returns me 404 error.

How can I make images accessible? (CORS already set for localhost:3000 and 3001 - ports of client side to the website itself and its CMS client)

My server is Debia 9 built in Apache and PHP 7.0.30

I’m a beginner on Slim Framework, if possible I’d like some reference to understand it better .

Thanks in advance


#2

If you are getting a 404, then it is probably not CORS.

Are you using a separate server for serving the React app, e.g. using Node? You may have to use an absolute URL with the correct port in the URL.