I have taken the build of angular project and got dist folder.when i am trying to open the index.html in browser.I am getting the following error like failed to load resources and file not found for inline.bundle.js ,polyfil.bundle.js and many files. Though this files added in the script tag and i didnt change the path of this file still not working.But if i run this from live server it is working. Explain why it is not working without server? Why it is not loading the inline.bundle.js,polyfill.bundle.js which are js file?
I have taken the build of angular project and got dist folder.when i am trying to open the index.html in browser.I am getting the following error like failed to load resources and file not found for inline.bundle.js ,polyfil.bundle.js and many files. Though this files added in the script tag and i didnt change the path of this file still not working.But if i run this from live server it is working. Explain why it is not working without server? Why it is not loading the inline.bundle.js,polyfill.bundle.js which are js file?
Share Improve this question edited Mar 15, 2018 at 16:25 David Walschots 12.6k5 gold badges38 silver badges59 bronze badges asked Mar 7, 2018 at 9:54 John WillsonJohn Willson 4551 gold badge3 silver badges14 bronze badges 1 |3 Answers
Reset to default 13Your files are not found because base URL changed.
You can workaround this one by using <base href="./">
in your index.html
.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
You can also use the ng build --base-href ./
command, so that modifying the HTML file is not necessary.
According to Mozilla:
The HTML <base> element specifies the base URL to use for
all relative URLs in a document. There can be only one <base> element in a document.
This means all the compiled resources are being referenced in relation to the root of the system. for instance the style and the images are in the same folder as the index.html. making the base url <base href="/">
or <base href="foldername of the index.html">
makes it to reference to the current folder.
localhost:4200
, it is said when you runng start
. – Akxe Commented Jan 11, 2019 at 13:08