I have folder structure like:
I have 2 code:
- components > cards.js
<img src="path here" />
- App.css
background-image: url("./images/img-1.jpg");
questions. Why the example 1 can access the public folder while 2 can't?
I have folder structure like:
I have 2 code:
<img src="path here" />
background-image: url("./images/img-1.jpg");
questions. Why the example 1 can access the public folder while 2 can't?
Because the path url("./images/img-1.jpg") is a relative file, not a url. Change it to url("/images/img-1.jpg") or url("<base_href>/images/img-1.jpg") if you're behind a reverse proxy.
Error: Can't resolve '/images/img-2.jpg'img-1.jpg in src/images/ or public/images/?src/images doesnt exist. I dont know which error is it. Like I try to access 1 image; 1.access from js file 2.access from css file..npm start or when visiting the site you see it in console logs?