Inorder to handle 404 request from a client side application, the Microsoft.AspNetCore.SpaServices NuGet package includes a routing helper called MapSpaFallbackRoute to avoid to navigate to an invalid url. In the below code it’s always fallback to the home page.