Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular CLI - ng serve

I know that the command "ng serve" creates all my stuff in memory.

Now I have such url: http://localhost:4200/some-angular-route But I want this url: http://localhost:4200/subfolder/some-angular-route

My Question is how can I create such a "subfolder"? My Problem is that in my production environment the requests go via Spring Boot Zuul and there are prefixes at urls.

like image 750
Mateusz Klimentowicz Avatar asked Jan 04 '23 20:01

Mateusz Klimentowicz


1 Answers

You can set base href as follows

@NgModule({
  imports: [
    RouterModule.forRoot(routes)
  ],
  declarations: [AppComponent],
  providers: [{ provide: APP_BASE_HREF, useValue: '/urlPrefix' }]
})
export class AppModule { }

Also, when you build your code, you can give --directory and --baseHref as follows.

ng build --deploy-url /mySubFolder/ --base-href /urlPrefix/

You can find more here https://github.com/angular/angular-cli/wiki/build

like image 76
Bunyamin Coskuner Avatar answered Jan 20 '23 02:01

Bunyamin Coskuner