I'm building a system that consists of multiple microservices, databases, a message broker, and a file storage system that primarily stores photos. In my setup, I'm using MinIO as my file storage solution, which is deployed via Docker. The entire infrastructure is behind an API gateway.
I need to allow the frontend to display images by embedding them directly in an tag. To do this, the frontend must receive a URL that points to the file storage. Given that all components are secured behind the API gateway, I'm considering several approaches to organize file storage access:
- Proxy via a dedicated endpoint: Create a dedicated API endpoint in one of the microservices that internally fetches the image from the file storage and returns it to the frontend.
- Direct link with API gateway proxying: Generate a direct link to the file storage and return it to the frontend, with requests being proxied through the API gateway.
- Direct link bypassing the API gateway: Generate a direct link to the file storage and return it to the frontend, bypassing the API gateway altogether.
Which of my options is the best? Are there any best practices or alternative strategies that should be considered?