My backend is based on Django and its REST framework.
I am serving images via an HTTPresponse. Since those images contain really sensitive data, I force the clients to authenticate themselves by sending a TOKEN within the header.
The URL is something like www.mywebsite.de/api/images/<id>
.
My frontend is based on ReactJS.
In order to embed those pictures on the frontend, I fetch them using axios. Afterwards I encode them using base64 and place the URI into the src property on a <img />
tag
Now, thing is I read alot of downsides of base64 encoded images, like bloated size, caching problems an so on... some are listed here: https://medium.com/snapp-mobile/dont-use-base64-encoded-images-on-mobile-13ddeac89d7c
I am asking myself now, as a beginner: What are the alternatives? How can I embed those images without Base64? I cannot serve a static URL, that's for sure. Furthermore I cannot tell the img-tag to use a authorization header.
I would be thankful for any hint into the right direction.
Thank you in advance :)