By default .UseSpa() in startup.cs catches every request that arrives to its point of the pipeline, and tries to handle it as a request to the SPA main page
I want to keep 404 for for my API calls at route /api/* just in case when typo in api url is made it my logger would log 404 and and not like "Error Code: 200 Message: Http failure during parsing for https://localhost:5001/api/non-existing-api-should-give-404" (because it got index.html in response)
Already spend over day on this and I can't find solution :( UseSpa() seems to overwrite any not matched endpoint. Any ideas how to solve it?
Here is basic configure from Startup.cs, problem is in Production Environment.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseHttpsRedirection();
if (!env.IsDevelopment())
{
app.UseSpaStaticFiles();
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.UseSpa(spa =>
{
if (env.IsDevelopment())
{
spa.UseProxyToSpaDevelopmentServer("http://127.0.0.1:4200");
}
});
}