When on the remote server, my js file cannot access the svg image. But on my local host it's ok

I've a js file in my js folder. I've a SVG image in my image folder. I'm trying to acces my image when the page loads (document.addEventListener('domContentLoaded', (e) => {})) through this js file but it can't reach the image. The strange thing is that on Live Server it works, while on Github pages it doesn't work, while offline it doesn't work either... I don't understand. The path is perfect, but depending on where the upload takes place (live server, offline or GitHub pages) it bugs and the image is not displayed! Could you guys help me?
5 Replies
dys 🐙
dys 🐙17mo ago
Is this a public repo? Do you see a request for the correct image in the network tab of the dev tools? Or is there a 404?
astroperseus_g
astroperseus_g17mo ago
404 it's weird, it works in a server but not on the other...
dys 🐙
dys 🐙17mo ago
What's the URL for the 404? It works on a server where it is served from the root, but not on GitHub Pages where it is served from a subdirectory? Is it possible resources are trying to load from the root?
Myndi
Myndi17mo ago
Could you share your account or repositories? With GitHub pages you have a main page with same www.example.com anything that comes afterwards will be www.example.com/whatever. I had a similar issue back then, that it was trying to access the main domain's images, instead of that specific project, since they shared the same base domain.
astroperseus_g
astroperseus_g17mo ago
hey guys, I really apreciate your time, thank you for your help. But I'm gonna try again after some time, after I learn somethings more. Thanks gain
Want results from more Discord servers?
Add your server