I have a ASP.NET Core 2.2 application with Vue.js for my frontend. In my startup I have the following routes:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "mvc",
template: "{controller=Home}/{action=Index}/{id?}");
// TODO: When api route doesn't exists it goes into the spa-fallkback route. We need to prevent this.
routes.MapSpaFallbackRoute(
name: "spa-fallback",
defaults: new { controller = "Home", action = "Index" });
});
The problem is with my API routes. When the API URL exists we have no problem, but when the URL doesn't exist, it goes to the spa-fallback routes.
Is there a way to set up the routes so that when the URL starts with /api/ and no route is found, it returns a 404 instead of the spa-fallback?