Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 6226d9d

Browse files
javascript ui now uses absolute urls so simply forward
1 parent 9f3c341 commit 6226d9d

2 files changed

Lines changed: 11 additions & 22 deletions

File tree

src/SqlStreamStore.HAL.DevServer/DevServerStartup.cs

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void Configure(IApplicationBuilder app) => app
3535
.UseResponseCompression()
3636
.Use(VaryAccept)
3737
.Use(CatchAndDisplayErrors)
38-
.Use(SqlStreamStreamBrowserJavascript)
38+
.Use(SqlStreamStreamBrowserStatic)
3939
.Use(SqlStreamStreamBrowserHtml)
4040
.UseSqlStreamStoreHal(_streamStore);
4141

@@ -55,34 +55,25 @@ public void Configure(IApplicationBuilder app) => app
5555
{
5656
Task Vary(object state)
5757
{
58-
var response = (HttpResponse)state;
58+
var response = (HttpResponse) state;
5959

6060
response.Headers.AppendCommaSeparatedValues("Vary", "Accept");
6161

6262
return Task.CompletedTask;
6363
}
64-
64+
6565
context.Response.OnStarting(Vary, context.Response);
66-
66+
6767
return next();
6868
};
6969

70-
private MidFunc SqlStreamStreamBrowserJavascript => (context, next) =>
71-
{
72-
if(context.Request.Path.Value?.EndsWith(".js") ?? false)
73-
{
74-
var segments = context.Request.Path.ToUriComponent().Split('/');
75-
if(segments.Length > 2)
76-
{
77-
return RedirectToPathBase(context, $"/{segments.Last()}");
78-
}
79-
80-
return ForwardToClientDevServer(
70+
private MidFunc SqlStreamStreamBrowserStatic => (context, next)
71+
=> context.Request.Path.StartsWithSegments(new PathString("/static"))
72+
|| context.Request.Path.StartsWithSegments(new PathString("/sockjs-node"))
73+
? ForwardToClientDevServer(
8174
context,
82-
context.Request.PathBase + context.Request.Path);
83-
}
84-
return next();
85-
};
75+
context.Request.Path)
76+
: next();
8677

8778
private MidFunc SqlStreamStreamBrowserHtml => (context, next)
8879
=> GetAcceptHeaders(context.Request)
@@ -100,7 +91,7 @@ private static string[] GetAcceptHeaders(HttpRequest contextRequest)
10091
private Task RedirectToPathBase(HttpContext context, PathString path)
10192
{
10293
context.Response.Redirect(context.Request.PathBase + path);
103-
94+
10495
return Task.CompletedTask;
10596
}
10697

src/SqlStreamStore.HAL.DevServer/Program.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
namespace SqlStreamStore.HAL.DevServer
22
{
3-
using System;
4-
using System.Linq;
53
using System.Threading;
64
using System.Threading.Tasks;
75
using Microsoft.AspNetCore.Hosting;

0 commit comments

Comments
 (0)