I am building a dockerized personal portfolio using Django, React and PostgreSQL. The issue is, the images I am using are not found by the server in the deployed environment.
I am using digitalocean to deploy my portfolio by creating a droplet. I have already uploaded the images in django admin and I am fetching those via API in the react-frontend. This is working fine in the local environment, but the files are not found by the server in the deployed environment. I have tried using NginX for this as well but the issue persists. When I tried to locate that image via django admin panel again, status code 404 is there.
Not Found
The requested resource was not found on this server.
By this, at least I understood that the images I uploading to django admin are not being done successfully. However, when I check the media/images folder, inside the linux server, I can see all uploaded images.

I am using media_url in settings.py like this:
BASE_DIR = Path(__file__).resolve().parent.parent`
MEDIA_URL = 'media/'
MEDIA_ROOT = BASE_DIR / 'media'
I have tried to use NginX by installing it in the droplet and the updated the config file like this:
server {
...
location /media/ {
alias /home/kishan/my-portfolio/backend/media/images/;
expires 30d; # Adjust cache expiration as needed
}
...
}
I added the media location so that nginx can serve the media files. I am not sure how to use nginx properly yet. But thought I should try and it did not work. The status 404 is there.