这个问题可能是因为API路由没有正确配置而导致的。为了解决此问题,您可以将以下代码添加到Startup.cs文件的Configure方法中:
app.Use(async (context, next) => { await next(); if (context.Response.StatusCode == 404 && !Path.HasExtension(context.Request.Path.Value) && !context.Request.Path.Value.StartsWith("/api/")) { context.Response.Redirect("/index.html"); } });
这将确保在API路由无效或未找到时,返回404而不是HTML。
上一篇:BlazorWASM/Server无法在IOS上读取带透明通道的视频(?)
下一篇:BlazorWASM:BlankPage-TypeErrorFailedtofetch;undefinedTypeError:Failedtofetch