I am new to Angular. I created a small web application with 2 images. The images are in myapp/src/assets/img1.jpg. On my local machine, everything works fine. When I call locasthost:4200 I can see the images, but when I upload the content of the dist folder (created with ng build --prod) to my web server, the images cannot be found.
my web server: abc.host.com/~user1/myapp
Parts (myapp) of the path are cut off. e.g. abc.host.com/~user1/assets/img1.jpg.
What <base href=""> should I use?
What img src path to use so that images are shown on web server too?
the following did not work:
<img src="/assets/img/img1.jpg" alt="/assets/img/img1.jpg">
<img src="../assets/img/img1.jpg" alt="../assets/img/img1.jpg">
I would like to keep everything relative.
SOLUTION:
- use
<base href="./">in your index.html <img src="assets/img/img1.jpg" alt="assets/img/img1.jpg">
My web server will now get the img from: abc.host.com/~user1/myapp/assets/img/img1.jpg