I have an Angular and Spring Boot project built with maven. Angular contains parameterized routes. After building and launching the project, the home url localhost:9090 looks fine. Navigating to localhost:9090/message/100004 for example, returns a blank page with network stating that scripts haven't loaded due to a 404 Error status.
Examples of 404 responses:
runtime.bf83fefcacda138fd53d.js 404 script 100001
polyfills.26120b3a7894b84ac5a0.js 404 script 100001
Request URL: http://localhost:9090/message/runtime.bf83fefcacda138fd53d.js
Request Method: GET
Status Code: 404
Remote Address: [::1]:9090
Referrer Policy: strict-origin-when-cross-origin
More detailed, the requested URL is wrong, since it adds "/message/ to the path, thus showing a blank page (i guess).
My guess is, that I have a fallback error since Spring Boot tries to process the URL but can't find any file since Angular (should) manage the routing. I've looked into solutions as described here: Angular Fallback Documenation and Stackoverflow/38516667 but none worked for me.
Here are some snippets:
Angular
import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import { DataprivacyComponent } from './components/dataprivacy/dataprivacy.component';
import { FaqComponent } from './components/faq/faq.component';
import { LegalnoticeComponent } from './components/legalnotice/legalnotice.component';
import {LoginComponent} from './components/login/login.component';
const routes: Routes = [
{ path: '', component: LoginComponent},
{ path: 'message/:id', component: LoginComponent},
{ path: 'faq', component: FaqComponent},
{ path: 'dataprivacy', component: DataprivacyComponent},
{ path: 'legalnotice', component: LegalnoticeComponent},
{ path: '**', redirectTo: '', pathMatch: 'full'}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
Structure
I tried some SpringBoot Configs but am not that familiar with it thus failed. Hope someone knows better! Thx