Angular throws 404 for * .bundle.js files when using custom html5 base url
Symptom
After upgrading my Angular2 app to Angular ^4.1.2
and also the Angular beta for ^1.0.3
, I got a 404 not found for my * .bundle.js files when I run the app with ng serve
. Please note that this symptom was not seen in the Angular2 beta and Angular CLI.
Setting up
This problem only exists when I set the base url html5 to a custom url in index.html
eg. <base href="/some-path/">
... (Ie, if I install it on <base href="/">
, the files *.bundle.js
are located and my application works)
Study
The symptom happens in the circumstances described because the files are served at the root level using Angular cli, no matter what the base url is html5. So the real question is: How can I tell Angular CLI to serve * .bundle.js files at a specified base url OR tell Angular to pick up root files? I found a release question that seems to address exactly this issue. Therefore ng serve
, ng build
there is an option for teams --base-href
.
I have tried using these options both isolated and combined:
-
ng serve --base-href /assessment/
-
ng serve --base-href /assessment/ --deploy-url /assessment/
However, the symptom remained.
source to share