Note that fetch is located in the frontend project and executed on client-side (browsers). Therefore, localhost resolves to the user's computer, not your server.
fetch
localhost
You can simply replace localhost with your deployed server IP/domain.