Skip to content

Commit 097101a

Browse files
committed
PR feedback
1 parent f7f946a commit 097101a

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/Components/WebAssembly/DevServer/src/Server/Startup.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,17 @@ public static void Configure(IApplicationBuilder app, IConfiguration configurati
3535

3636
app.Use(async (ctx, next) =>
3737
{
38-
if (ctx.Request.Path.StartsWithSegments("/_framework") && !ctx.Request.Path.StartsWithSegments("/_framework/blazor.server.js") && !ctx.Request.Path.StartsWithSegments("/_framework/blazor.web.js"))
38+
if (ctx.Request.Path.StartsWithSegments("/_framework/blazor.boot.json"))
3939
{
4040
ctx.Response.Headers.Append("Blazor-Environment", webHostEnvironment.EnvironmentName);
41-
42-
if (applyCopHeaders)
41+
}
42+
else if (applyCopHeaders && ctx.Request.Path.StartsWithSegments("/_framework") && !ctx.Request.Path.StartsWithSegments("/_framework/blazor.server.js") && !ctx.Request.Path.StartsWithSegments("/_framework/blazor.web.js"))
43+
{
44+
var fileExtension = Path.GetExtension(ctx.Request.Path);
45+
if (string.Equals(fileExtension, ".js", StringComparison.Ordinal))
4346
{
44-
var fileExtension = Path.GetExtension(ctx.Request.Path);
45-
if (string.Equals(fileExtension, ".js", StringComparison.Ordinal))
46-
{
47-
// Browser multi-threaded runtime requires cross-origin policy headers to enable SharedArrayBuffer.
48-
ApplyCrossOriginPolicyHeaders(ctx);
49-
}
47+
// Browser multi-threaded runtime requires cross-origin policy headers to enable SharedArrayBuffer.
48+
ApplyCrossOriginPolicyHeaders(ctx);
5049
}
5150
}
5251

src/Components/test/E2ETest/Tests/WebAssemblyConfigurationTest.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public void WebAssemblyConfiguration_Works()
3737
// Verify values from the default 'appsettings.json' are read.
3838
Browser.Equal("Default key1-value", () => _appElement.FindElement(By.Id("key1")).Text);
3939

40-
// Verify that the dev server always correctly serves the 'Blazor-Environment: Development' header.
41-
Browser.Equal("Development", () => _appElement.FindElement(By.Id("environment")).Text);
42-
4340
if (_serverFixture.TestTrimmedOrMultithreadingApps)
4441
{
42+
// Verify that the environment gets detected as 'Production'.
43+
Browser.Equal("Production", () => _appElement.FindElement(By.Id("environment")).Text);
44+
4545
// Verify values overriden by an environment specific 'appsettings.$(Environment).json are read
4646
Assert.Equal("Prod key2-value", _appElement.FindElement(By.Id("key2")).Text);
4747

@@ -50,6 +50,9 @@ public void WebAssemblyConfiguration_Works()
5050
}
5151
else
5252
{
53+
// Verify that the dev server always correctly serves the 'Blazor-Environment: Development' header.
54+
Browser.Equal("Development", () => _appElement.FindElement(By.Id("environment")).Text);
55+
5356
// Verify values overriden by an environment specific 'appsettings.$(Environment).json are read
5457
Assert.Equal("Development key2-value", _appElement.FindElement(By.Id("key2")).Text);
5558

0 commit comments

Comments
 (0)