Fix the Whitelabel error in Angular and Spring Boot


Angular is a frontend application and doesn't manage directly url adresses like ''. The request from your browser goes to the server that cannot find the 'myPage' page because is declared in your Angular routing.

Whitelabel Error Page 
This application has no explicit mapping for /error, so you are seeing this as a fallback. 
Sun Mar 07 09:22:25 UTC 2021 
There was an unexpected error (type=Not Found, status=404). 

You can quickly fix the problem rerouting the pages that Spring cannot find to the root of the website.

The router of Angular will display the correct page.

public class WebRoutingConfig implements WebMvcConfigurer { 
  public void addViewControllers(ViewControllerRegistry registry) { 
      // the viewName should be specified, in our case we forward to the index.html 
  public WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> containerCustomizer() { 
     return container -> { 
       container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, 

A more specific post about how to handle the Whitelabel Error in Spring is here:

Fullstack Angular / Java application quick start guide.
WebApp built by Marco using SpringBoot 3.2.4 and Java 21. Hosted in Switzerland (GE8).