This article is a mirror article of machine translation, please click here to jump to the original article.

View: 15994|Reply: 0

[Angular] Angular base href tag

[Copy link]
Posted on 3/5/2020 9:14:07 PM | | | |
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.





Previous:Android Casio 991es computer
Next:Clock on the hour on the desktop
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com