App, deployed on github pages, sends GET for assets to wrong address

avatar
10    2 months ago

I have built my app using:

ng build --prod --base-href https://3hdw.github.io/zpi-frontend/

I noticed that deployed app doesn't load some images. 

Properly loaded images are obtained by GET sent to this address: https://3hdw.github.io/zpi-frontend/assets/fileName 
and for some reason app tries to load other images using wrong address: https://3hdw.github.io/assets/fileName, which results in not loading some assets.

I noticed this behaviour after updating my angular project.

EDIT:

Not loaded images are specified with css: background-image: url("/assets/fileName");
Loaded images are specified with html: <img src="assets/fileName"/>

after changing url("/assets/fileName") to url("/zpi-frontend/assets/fileName") images are being loaded but there should be better solution

Answers { 1 }
avatar
2 months ago

Try using the --deployUrl when running the ng build command. That will set the assets prefix.