base tag
<base href="..."/> in HTML is used to specify a base address for resolving relative paths, such as images, scripts, and stylesheets. For example, if you specify <base href="/my/app/">, the browser will parse a URL like some/place/foo.jpg into a server-side request to my/app/some/place/foo.jpg. During browsing, the Angular router uses the base href as the base address for component, template, and module files.
During development, you usually start the server in the directory where index.html resides. This directory is the root directory, and since / is the root of this application, you need to add the <base href="/" > to the top of the index.html.
However, on a shared server or production server, you may have to start the server from a subdirectory. For example, when loading the URL of this application ishttp://www.mysite.com/my/app/The subdirectory is my/app/, and you need to add <base href="/my/app/" > to the server version of index.html.
When the base tag is not configured, the app fails to load and some 404 - Not Found errors are displayed in the browser's console for these missing files. Look at where the browser is trying to find these files and adjust the appropriate base tags.
|