Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

override baseHref for ng serve in Angular 14

I have a set "baseHref" to '/bui' in the angular.json file because the static files are deployed there. If I use ng serve with port 4200 and I navigate to https://localhost:4200 I get the following message: Cannot GET /

This is due to the baseHref. In the past we would use a base href set to '/' and the deployUrl set to '/bui/'. The deployUrl is now deprecated (Angular 14) so we have to use base href.

In production mode on the server the base href is /something-extra/bui/. We also want to use the application with base href /bui/ in case we test the application with aspnet core and the static files (wwwroot).

I cannot seem to override the baseHref within the ng-serve section of the angular.json file. How can I override the base href in ng serve modus to '/'?

like image 654
stephan.peters Avatar asked Oct 25 '25 10:10

stephan.peters


1 Answers

angular.json

.
.
.
 "configurations": {
            "development": {
              "baseHref": "/",
.
.
.
"production": {
              "baseHref": "/bui/",

index.html

.
.
.
<base href="/">
...
like image 65
Robin Webb Avatar answered Oct 28 '25 01:10

Robin Webb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!