懒得勤快 пре 4 година
родитељ
комит
e92b03643e

+ 2 - 1
src/Masuit.MyBlogs.Core/Extensions/TranslateMiddleware.cs

@@ -26,7 +26,8 @@ namespace Masuit.MyBlogs.Core.Extensions
 
 
         public Task Invoke(HttpContext context)
         public Task Invoke(HttpContext context)
         {
         {
-            if (context.Request.IsRobot())
+            var path = context.Request.Path.Value ?? "";
+            if (path.StartsWith("/_blazor") || path.StartsWith("/api") || context.Request.IsRobot())
             {
             {
                 return _next(context);
                 return _next(context);
             }
             }

+ 1 - 1
src/Masuit.MyBlogs.Core/Startup.cs

@@ -151,7 +151,7 @@ namespace Masuit.MyBlogs.Core
             app.UseWhen(c => !c.Request.Path.StartsWithSegments("/_blazor"), builder => builder.UseMiddleware<RequestInterceptMiddleware>()); //启用网站请求拦截
             app.UseWhen(c => !c.Request.Path.StartsWithSegments("/_blazor"), builder => builder.UseMiddleware<RequestInterceptMiddleware>()); //启用网站请求拦截
             app.SetupHangfire();
             app.SetupHangfire();
             app.UseResponseCaching().UseResponseCompression(); //启动Response缓存
             app.UseResponseCaching().UseResponseCompression(); //启动Response缓存
-            app.UseWhen(c => !c.Request.Path.StartsWithSegments("/_blazor"), builder => builder.UseMiddleware<TranslateMiddleware>());
+            app.UseMiddleware<TranslateMiddleware>();
             app.UseRouting().UseEndpoints(endpoints =>
             app.UseRouting().UseEndpoints(endpoints =>
             {
             {
                 endpoints.MapBlazorHub(options =>
                 endpoints.MapBlazorHub(options =>