Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React images load locally but not on AWS Amplify

Hi I am working with an API that retrieves the URL of an image. I am then trying to pass that URL into an tag as follows:

<img class="img-fluid" src={this.state.representatives[i].pic}/>

Locally I am met with

Local server

But when I try to use the app on AWS Amplify, I am met with:

enter image description here

I have tried hardcoding the URL into the app but it returns the same error. I am really confused where to go from here.

For example the image URL pulled from the API for Mark Warner is http://bioguide.congress.gov/bioguide/photo/W/W000805.jpg

and I know I am not messing with this URL as it loads locally. Am I making a simple error somewhere?

like image 556
brennan mcgowan Avatar asked Dec 08 '22 10:12

brennan mcgowan


2 Answers

Go to App Settings -> Redirects and Rewrites and change the

source address: </^[^.]+$|.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/>

Type from 200 (Rewrite) to 404 (Rewrite)

like image 191
Ammar T. Avatar answered Dec 23 '22 06:12

Ammar T.


I appreciate Ammar T.'s answer, but I just add some cherry to his answer. So if your binary file extension is something else, which is not available in the

</^[^.]+$|.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/>

this, then just add that extension into it. i.e I was using a .jpeg file, so for me I had to modify it into

</^[^.]+$|.(?!(css|gif|ico|jpg|jpeg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/>

this.

Thanks

like image 20
imjoymhnt Avatar answered Dec 23 '22 06:12

imjoymhnt