Skip to content

Commit

Permalink
Fix fonts failing to load
Browse files Browse the repository at this point in the history
  • Loading branch information
bzaar committed Dec 8, 2023
1 parent 4386c5e commit b6112e8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions gramdictru/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -62,13 +63,13 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)

private static async Task NowrapMiddleware(HttpContext context, Func<Task> next)
{
if (context.Request.Path.HasValue && context.Request.Path.Value.StartsWith("/js/"))
if (context.Request.Headers["Accept"].Any(h => h.StartsWith("text/html")))
{
await next.Invoke();
await PostProcessHtml(context, next);
}
else
{
await PostProcessHtml(context, next);
await next.Invoke();
}
}

Expand All @@ -85,6 +86,7 @@ private static async Task PostProcessHtml(HttpContext context, Func<Task> next)
string body = await new StreamReader(memoryStream).ReadToEndAsync();
string newBody = PageHtmlPostProcessor.AddNoWrap(body);
byte[] bytes = Encoding.UTF8.GetBytes(newBody);
response.ContentLength = bytes.Length;
await oldStream.WriteAsync(bytes, 0, bytes.Length);
response.Body = oldStream;
}
Expand Down

0 comments on commit b6112e8

Please sign in to comment.