0

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.

network response

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).

enter image description here

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

enter image description here

I tried some SpringBoot Configs but am not that familiar with it thus failed. Hope someone knows better! Thx

letsgetraw
  • 193
  • 1
  • 10
  • 1
    Please read [ask], where it says "**DO NOT post images of code, data, error messages, etc.** - copy or type the text into the question." Also, Angular is very different from AngularJS. Please use only the tag of the framework you are actually using. – Heretic Monkey Oct 19 '21 at 14:30
  • I'm sorry! Nevertheless, I think providing the network snippets are sufficient by image. The code and links are text. – letsgetraw Oct 19 '21 at 14:33
  • 2
    As long as you don't mind your question being read as "...returns a blank page with network stating: network response" to blind users and search engines. – Heretic Monkey Oct 19 '21 at 14:36

0 Answers0