Skip to content

Commit 95dfc2f

Browse files
Hub service: rewrite ui requests to app path
1 parent 26eff26 commit 95dfc2f

File tree

1 file changed

+13
-0
lines changed
  • src/Certify.Server/Certify.Server.HubService

1 file changed

+13
-0
lines changed

src/Certify.Server/Certify.Server.HubService/Program.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,19 @@
316316
description: $"Hub API docs available at /api/docs"
317317
);
318318

319+
// if request is for /ui/ then we are following a route intended for the Blazor UI, so rewrite the request to / to serve index.html
320+
// https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-9.0
321+
app.Use((context, next) =>
322+
{
323+
if (context.Request.Path.StartsWithSegments("/ui"))
324+
{
325+
// Rewrite the request path to serve index.html
326+
context.Request.Path = "/";
327+
}
328+
329+
return next(context);
330+
});
331+
319332
// configure initialization of UI status hub, backend management hub etc
320333

321334
var statusHubContext = app.Services.GetRequiredService<IHubContext<UserInterfaceStatusHub>>();

0 commit comments

Comments
 (0)