Reputation: 4093
I have angular app (with spring boot on backend)
here are my routes:
export const routes: Routes = [
{ path: '', redirectTo: 'intro', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
// LANGUAGES
{ path: 'english', component: LanguageComponent },
{ path: 'spanish', component: LanguageComponent },
// CITIES
{ path: 'alexandria', component: CityComponent },
{ path: 'ankara', component: CityComponent }];
export const router: ModuleWithProviders = RouterModule.forRoot(routes, { useHash: false, initialNavigation: true });
And now the funny behavior:
When I route in the app ( = clicking the button/link tags having routerLink ) everything works ok, but when I directly insert url into the browser, I got following:
localhost:8080/english -> Whitelabel Error Page (default spring boot 404 page). (for any language)
localhost:8080/alexandria -> Works as expected (for any city)
When I run the frontend on a separate server (localhost:4200), everything works as expected.
Upvotes: 1
Views: 1243
Reputation: 28592
You must configure your spring boot to redirect everything to index.html
.
Because when the request hits your server, unless you redirect to angular app (index.html
), Angular app won't run, then your routing configuration in Angular isn't worth.
Upvotes: 1